diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/sync.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 4689ac8b..93010c51 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -28,6 +28,14 @@ try: | |||
| 28 | except ImportError: | 28 | except ImportError: |
| 29 | import dummy_threading as _threading | 29 | import dummy_threading as _threading |
| 30 | 30 | ||
| 31 | try: | ||
| 32 | import resource | ||
| 33 | def _rlimit_nofile(): | ||
| 34 | return resource.getrlimit(resource.RLIMIT_NOFILE) | ||
| 35 | except ImportError: | ||
| 36 | def _rlimit_nofile(): | ||
| 37 | return (256, 256) | ||
| 38 | |||
| 31 | from git_command import GIT | 39 | from git_command import GIT |
| 32 | from git_refs import R_HEADS | 40 | from git_refs import R_HEADS |
| 33 | from project import HEAD | 41 | from project import HEAD |
| @@ -312,6 +320,10 @@ uncommitted changes are present' % project.relpath | |||
| 312 | def Execute(self, opt, args): | 320 | def Execute(self, opt, args): |
| 313 | if opt.jobs: | 321 | if opt.jobs: |
| 314 | self.jobs = opt.jobs | 322 | self.jobs = opt.jobs |
| 323 | if self.jobs > 1: | ||
| 324 | soft_limit, _ = _rlimit_nofile() | ||
| 325 | self.jobs = min(self.jobs, (soft_limit - 5) / 3) | ||
| 326 | |||
| 315 | if opt.network_only and opt.detach_head: | 327 | if opt.network_only and opt.detach_head: |
| 316 | print >>sys.stderr, 'error: cannot combine -n and -d' | 328 | print >>sys.stderr, 'error: cannot combine -n and -d' |
| 317 | sys.exit(1) | 329 | sys.exit(1) |
