Issue #28485: Merge single-threading fix from 3.5 into 3.6

This commit is contained in:
Martin Panter 2016-11-05 01:35:25 +00:00
commit cee93c3b73
2 changed files with 7 additions and 3 deletions

View file

@ -68,13 +68,13 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
optimize: optimization level or -1 for level of the interpreter
workers: maximum number of parallel workers
"""
if workers is not None and workers < 0:
raise ValueError('workers must be greater or equal to 0')
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels,
ddir=ddir)
success = True
if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
if workers < 0:
raise ValueError('workers must be greater or equal to 0')
workers = workers or None
with ProcessPoolExecutor(max_workers=workers) as executor:
results = executor.map(partial(compile_file,