summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--subcmds/sync.py12
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:
28except ImportError: 28except ImportError:
29 import dummy_threading as _threading 29 import dummy_threading as _threading
30 30
31try:
32 import resource
33 def _rlimit_nofile():
34 return resource.getrlimit(resource.RLIMIT_NOFILE)
35except ImportError:
36 def _rlimit_nofile():
37 return (256, 256)
38
31from git_command import GIT 39from git_command import GIT
32from git_refs import R_HEADS 40from git_refs import R_HEADS
33from project import HEAD 41from 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)