@@ -67,20 +67,20 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
6767 invalidation_mode: how the up-to-dateness of the pyc will be checked
6868 """
6969 ProcessPoolExecutor = None
70- if workers is not None :
71- if workers < 0 :
72- raise ValueError ('workers must be greater or equal to 0' )
73- elif workers != 1 :
74- try :
75- # Only import when needed, as low resource platforms may
76- # fail to import it
77- from concurrent .futures import ProcessPoolExecutor
78- except ImportError :
79- workers = 1
70+ if workers < 0 :
71+ raise ValueError ('workers must be greater or equal to 0' )
72+ if workers != 1 :
73+ try :
74+ # Only import when needed, as low resource platforms may
75+ # fail to import it
76+ from concurrent .futures import ProcessPoolExecutor
77+ except ImportError :
78+ workers = 1
8079 files = _walk_dir (dir , quiet = quiet , maxlevels = maxlevels ,
8180 ddir = ddir )
8281 success = True
83- if workers is not None and workers != 1 and ProcessPoolExecutor is not None :
82+ if workers != 1 and ProcessPoolExecutor is not None :
83+ # If workers == 0, let ProcessPoolExecutor choose
8484 workers = workers or None
8585 with ProcessPoolExecutor (max_workers = workers ) as executor :
8686 results = executor .map (partial (compile_file ,
@@ -290,9 +290,6 @@ def main():
290290 print ("Error reading file list {}" .format (args .flist ))
291291 return False
292292
293- if args .workers is not None :
294- args .workers = args .workers or None
295-
296293 if args .invalidation_mode :
297294 ivl_mode = args .invalidation_mode .replace ('-' , '_' ).upper ()
298295 invalidation_mode = py_compile .PycInvalidationMode [ivl_mode ]
0 commit comments