summaryrefslogtreecommitdiff
path: root/Lib/compileall.py
diff options
context:
space:
mode:
authorAntoine Pitrou <antoine@python.org>2019-05-15 23:45:18 +0200
committerGitHub <noreply@github.com>2019-05-15 23:45:18 +0200
commit1a2dd82f56bd813aacc570e172cefe55a8a41504 (patch)
tree2c8815834378688cb0fd7d6596eee4ae1aadefea /Lib/compileall.py
parentc981ad16b0f9740bd3381c96b4227a1faa1a88d9 (diff)
downloadcpython-git-1a2dd82f56bd813aacc570e172cefe55a8a41504.tar.gz
bpo-36786: Run compileall in parallel during "make install" (GH-13078)
Diffstat (limited to 'Lib/compileall.py')
-rw-r--r--Lib/compileall.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py
index aa65c6b904..49306d9dab 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -67,20 +67,20 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
invalidation_mode: how the up-to-dateness of the pyc will be checked
"""
ProcessPoolExecutor = None
- if workers is not None:
- if workers < 0:
- raise ValueError('workers must be greater or equal to 0')
- elif workers != 1:
- try:
- # Only import when needed, as low resource platforms may
- # fail to import it
- from concurrent.futures import ProcessPoolExecutor
- except ImportError:
- workers = 1
+ if workers < 0:
+ raise ValueError('workers must be greater or equal to 0')
+ if workers != 1:
+ try:
+ # Only import when needed, as low resource platforms may
+ # fail to import it
+ from concurrent.futures import ProcessPoolExecutor
+ except ImportError:
+ workers = 1
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 != 1 and ProcessPoolExecutor is not None:
+ # If workers == 0, let ProcessPoolExecutor choose
workers = workers or None
with ProcessPoolExecutor(max_workers=workers) as executor:
results = executor.map(partial(compile_file,
@@ -290,9 +290,6 @@ def main():
print("Error reading file list {}".format(args.flist))
return False
- if args.workers is not None:
- args.workers = args.workers or None
-
if args.invalidation_mode:
ivl_mode = args.invalidation_mode.replace('-', '_').upper()
invalidation_mode = py_compile.PycInvalidationMode[ivl_mode]