aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/compileall.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2023-02-02 15:50:35 -0800
committerGitHub <noreply@github.com>2023-02-02 15:50:35 -0800
commit0ca67e6313c11263ecaef7ce182308eeb5aa6814 (patch)
treeff302df77417456ee4dcf94082b6d942e320b13a /Lib/compileall.py
parent618b7a8260bb40290d6551f24885931077309590 (diff)
downloadcpython-0ca67e6313c11263ecaef7ce182308eeb5aa6814.tar.gz
cpython-0ca67e6313c11263ecaef7ce182308eeb5aa6814.zip
GH-84559: Deprecate fork being the multiprocessing default. (#100618)
This starts the process. Users who don't specify their own start method and use the default on platforms where it is 'fork' will see a DeprecationWarning upon multiprocessing.Pool() construction or upon multiprocessing.Process.start() or concurrent.futures.ProcessPool use. See the related issue and documentation within this change for details.
Diffstat (limited to 'Lib/compileall.py')
-rw-r--r--Lib/compileall.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py
index a388931fb5a..d394156cedc 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -97,9 +97,15 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False,
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels)
success = True
if workers != 1 and ProcessPoolExecutor is not None:
+ import multiprocessing
+ if multiprocessing.get_start_method() == 'fork':
+ mp_context = multiprocessing.get_context('forkserver')
+ else:
+ mp_context = None
# If workers == 0, let ProcessPoolExecutor choose
workers = workers or None
- with ProcessPoolExecutor(max_workers=workers) as executor:
+ with ProcessPoolExecutor(max_workers=workers,
+ mp_context=mp_context) as executor:
results = executor.map(partial(compile_file,
ddir=ddir, force=force,
rx=rx, quiet=quiet,