Chromium Code Reviews| Index: Tools/Scripts/webkitpy/common/system/executive.py |
| diff --git a/Tools/Scripts/webkitpy/common/system/executive.py b/Tools/Scripts/webkitpy/common/system/executive.py |
| index 4f2223efa9e2da4d00d5167c77a3fc7c0a328163..f52db0a1a4b25b76dc512d4861f0adb0c6722af9 100644 |
| --- a/Tools/Scripts/webkitpy/common/system/executive.py |
| +++ b/Tools/Scripts/webkitpy/common/system/executive.py |
| @@ -471,14 +471,17 @@ class Executive(object): |
| def run_in_parallel(self, command_lines_and_cwds, processes=None): |
| """Runs a list of (cmd_line list, cwd string) tuples in parallel and returns a list of (retcode, stdout, stderr) tuples.""" |
| assert len(command_lines_and_cwds) |
| + return self.map(_run_command_thunk, command_lines_and_cwds, processes) |
| - if sys.platform in ('cygwin', 'win32'): |
| - return map(_run_command_thunk, command_lines_and_cwds) |
| - pool = multiprocessing.Pool(processes=processes) |
| - results = pool.map(_run_command_thunk, command_lines_and_cwds) |
| - pool.close() |
| - pool.join() |
| - return results |
| + def map(self, thunk, arglist, processes=None): |
| + if sys.platform in ('cygwin', 'win32') or len(arglist) == 1: |
| + return map(thunk, arglist) |
| + pool = multiprocessing.Pool(processes=(processes or multiprocessing.cpu_count())) |
| + try: |
| + return pool.map(thunk, arglist) |
|
eseidel
2014/09/09 23:10:55
This may be incompatible with keyboard interrupts:
Dirk Pranke
2014/09/09 23:32:22
Could be. I can switch this to a fancier pool if n
|
| + finally: |
| + pool.close() |
| + pool.join() |
| def _run_command_thunk(cmd_line_and_cwd): |