diff options
Diffstat (limited to 'subcmds/branches.py')
-rw-r--r-- | subcmds/branches.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/subcmds/branches.py b/subcmds/branches.py index d5ea580c..2dc102bb 100644 --- a/subcmds/branches.py +++ b/subcmds/branches.py | |||
@@ -13,10 +13,10 @@ | |||
13 | # limitations under the License. | 13 | # limitations under the License. |
14 | 14 | ||
15 | import itertools | 15 | import itertools |
16 | import multiprocessing | ||
17 | import sys | 16 | import sys |
17 | |||
18 | from color import Coloring | 18 | from color import Coloring |
19 | from command import Command, DEFAULT_LOCAL_JOBS, WORKER_BATCH_SIZE | 19 | from command import Command, DEFAULT_LOCAL_JOBS |
20 | 20 | ||
21 | 21 | ||
22 | class BranchColoring(Coloring): | 22 | class BranchColoring(Coloring): |
@@ -102,15 +102,19 @@ is shown, then the branch appears in all projects. | |||
102 | out = BranchColoring(self.manifest.manifestProject.config) | 102 | out = BranchColoring(self.manifest.manifestProject.config) |
103 | all_branches = {} | 103 | all_branches = {} |
104 | project_cnt = len(projects) | 104 | project_cnt = len(projects) |
105 | with multiprocessing.Pool(processes=opt.jobs) as pool: | ||
106 | project_branches = pool.imap_unordered( | ||
107 | expand_project_to_branches, projects, chunksize=WORKER_BATCH_SIZE) | ||
108 | 105 | ||
109 | for name, b in itertools.chain.from_iterable(project_branches): | 106 | def _ProcessResults(_pool, _output, results): |
107 | for name, b in itertools.chain.from_iterable(results): | ||
110 | if name not in all_branches: | 108 | if name not in all_branches: |
111 | all_branches[name] = BranchInfo(name) | 109 | all_branches[name] = BranchInfo(name) |
112 | all_branches[name].add(b) | 110 | all_branches[name].add(b) |
113 | 111 | ||
112 | self.ExecuteInParallel( | ||
113 | opt.jobs, | ||
114 | expand_project_to_branches, | ||
115 | projects, | ||
116 | callback=_ProcessResults) | ||
117 | |||
114 | names = sorted(all_branches) | 118 | names = sorted(all_branches) |
115 | 119 | ||
116 | if not names: | 120 | if not names: |