diff options
-rw-r--r-- | subcmds/sync.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index b41b20b7..4bcd45d5 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -174,6 +174,11 @@ later is required to fix a server side protocol bug. | |||
174 | pass | 174 | pass |
175 | super()._Options(p) | 175 | super()._Options(p) |
176 | 176 | ||
177 | p.add_option('--jobs-network', default=None, type=int, metavar='JOBS', | ||
178 | help='number of network jobs to run in parallel (defaults to --jobs)') | ||
179 | p.add_option('--jobs-checkout', default=None, type=int, metavar='JOBS', | ||
180 | help='number of local checkout jobs to run in parallel (defaults to --jobs)') | ||
181 | |||
177 | p.add_option('-f', '--force-broken', | 182 | p.add_option('-f', '--force-broken', |
178 | dest='force_broken', action='store_true', | 183 | dest='force_broken', action='store_true', |
179 | help='obsolete option (to be deleted in the future)') | 184 | help='obsolete option (to be deleted in the future)') |
@@ -364,6 +369,7 @@ later is required to fix a server side protocol bug. | |||
364 | def _Fetch(self, projects, opt, err_event): | 369 | def _Fetch(self, projects, opt, err_event): |
365 | ret = True | 370 | ret = True |
366 | 371 | ||
372 | jobs = opt.jobs_network if opt.jobs_network else self.jobs | ||
367 | fetched = set() | 373 | fetched = set() |
368 | pm = Progress('Fetching', len(projects), delay=False) | 374 | pm = Progress('Fetching', len(projects), delay=False) |
369 | 375 | ||
@@ -391,7 +397,7 @@ later is required to fix a server side protocol bug. | |||
391 | return ret | 397 | return ret |
392 | 398 | ||
393 | # NB: Multiprocessing is heavy, so don't spin it up for one job. | 399 | # NB: Multiprocessing is heavy, so don't spin it up for one job. |
394 | if len(projects_list) == 1 or opt.jobs == 1: | 400 | if len(projects_list) == 1 or jobs == 1: |
395 | if not _ProcessResults(self._FetchProjectList(opt, x) for x in projects_list): | 401 | if not _ProcessResults(self._FetchProjectList(opt, x) for x in projects_list): |
396 | ret = False | 402 | ret = False |
397 | else: | 403 | else: |
@@ -409,7 +415,7 @@ later is required to fix a server side protocol bug. | |||
409 | else: | 415 | else: |
410 | pm.update(inc=0, msg='warming up') | 416 | pm.update(inc=0, msg='warming up') |
411 | chunksize = 4 | 417 | chunksize = 4 |
412 | with multiprocessing.Pool(opt.jobs) as pool: | 418 | with multiprocessing.Pool(jobs) as pool: |
413 | results = pool.imap_unordered( | 419 | results = pool.imap_unordered( |
414 | functools.partial(self._FetchProjectList, opt), | 420 | functools.partial(self._FetchProjectList, opt), |
415 | projects_list, | 421 | projects_list, |
@@ -463,6 +469,7 @@ later is required to fix a server side protocol bug. | |||
463 | err_results: A list of strings, paths to git repos where checkout failed. | 469 | err_results: A list of strings, paths to git repos where checkout failed. |
464 | """ | 470 | """ |
465 | ret = True | 471 | ret = True |
472 | jobs = opt.jobs_checkout if opt.jobs_checkout else self.jobs | ||
466 | 473 | ||
467 | # Only checkout projects with worktrees. | 474 | # Only checkout projects with worktrees. |
468 | all_projects = [x for x in all_projects if x.worktree] | 475 | all_projects = [x for x in all_projects if x.worktree] |
@@ -483,11 +490,11 @@ later is required to fix a server side protocol bug. | |||
483 | return True | 490 | return True |
484 | 491 | ||
485 | # NB: Multiprocessing is heavy, so don't spin it up for one job. | 492 | # NB: Multiprocessing is heavy, so don't spin it up for one job. |
486 | if len(all_projects) == 1 or opt.jobs == 1: | 493 | if len(all_projects) == 1 or jobs == 1: |
487 | if not _ProcessResults(self._CheckoutOne(opt, x) for x in all_projects): | 494 | if not _ProcessResults(self._CheckoutOne(opt, x) for x in all_projects): |
488 | ret = False | 495 | ret = False |
489 | else: | 496 | else: |
490 | with multiprocessing.Pool(opt.jobs) as pool: | 497 | with multiprocessing.Pool(jobs) as pool: |
491 | results = pool.imap_unordered( | 498 | results = pool.imap_unordered( |
492 | functools.partial(self._CheckoutOne, opt), | 499 | functools.partial(self._CheckoutOne, opt), |
493 | all_projects, | 500 | all_projects, |