diff options
Diffstat (limited to 'subcmds/prune.py')
-rw-r--r-- | subcmds/prune.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/subcmds/prune.py b/subcmds/prune.py index f99082a4..18bfc680 100644 --- a/subcmds/prune.py +++ b/subcmds/prune.py | |||
@@ -27,8 +27,10 @@ class Prune(PagedCommand): | |||
27 | """ | 27 | """ |
28 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS | 28 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS |
29 | 29 | ||
30 | def _ExecuteOne(self, project): | 30 | @classmethod |
31 | def _ExecuteOne(cls, project_idx): | ||
31 | """Process one project.""" | 32 | """Process one project.""" |
33 | project = cls.get_parallel_context()["projects"][project_idx] | ||
32 | return project.PruneHeads() | 34 | return project.PruneHeads() |
33 | 35 | ||
34 | def Execute(self, opt, args): | 36 | def Execute(self, opt, args): |
@@ -41,13 +43,15 @@ class Prune(PagedCommand): | |||
41 | def _ProcessResults(_pool, _output, results): | 43 | def _ProcessResults(_pool, _output, results): |
42 | return list(itertools.chain.from_iterable(results)) | 44 | return list(itertools.chain.from_iterable(results)) |
43 | 45 | ||
44 | all_branches = self.ExecuteInParallel( | 46 | with self.ParallelContext(): |
45 | opt.jobs, | 47 | self.get_parallel_context()["projects"] = projects |
46 | self._ExecuteOne, | 48 | all_branches = self.ExecuteInParallel( |
47 | projects, | 49 | opt.jobs, |
48 | callback=_ProcessResults, | 50 | self._ExecuteOne, |
49 | ordered=True, | 51 | range(len(projects)), |
50 | ) | 52 | callback=_ProcessResults, |
53 | ordered=True, | ||
54 | ) | ||
51 | 55 | ||
52 | if not all_branches: | 56 | if not all_branches: |
53 | return | 57 | return |