Skip to content

Commit 078fcc3

Browse files
Eclips4youknowone
authored andcommitted
Update compileall.py and test_compileall.py
1 parent 3d78ca8 commit 078fcc3

File tree

2 files changed

+1149
-1
lines changed

2 files changed

+1149
-1
lines changed

Lib/compileall.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False,
9797
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels)
9898
success = True
9999
if workers != 1 and ProcessPoolExecutor is not None:
100+
import multiprocessing
101+
if multiprocessing.get_start_method() == 'fork':
102+
mp_context = multiprocessing.get_context('forkserver')
103+
else:
104+
mp_context = None
100105
# If workers == 0, let ProcessPoolExecutor choose
101106
workers = workers or None
102-
with ProcessPoolExecutor(max_workers=workers) as executor:
107+
with ProcessPoolExecutor(max_workers=workers,
108+
mp_context=mp_context) as executor:
103109
results = executor.map(partial(compile_file,
104110
ddir=ddir, force=force,
105111
rx=rx, quiet=quiet,

0 commit comments

Comments
 (0)