Skip to content

Fix EM_PYTHON_MULTIPROCESSING under windows #17892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,19 @@ def run_multiple_processes(commands,
if env is None:
env = os.environ.copy()

# By default, avoid using Python multiprocessing library due to a large amount of bugs it has on Windows (#8013, #718, #13785, etc.)
# Use EM_PYTHON_MULTIPROCESSING=1 environment variable to enable it. It can be faster, but may not work on Windows.
# By default, avoid using Python multiprocessing library due to a large amount
# of bugs it has on Windows (#8013, #718, etc.)
# Use EM_PYTHON_MULTIPROCESSING=1 environment variable to enable it. It can be
# faster, but may not work on Windows.
if int(os.getenv('EM_PYTHON_MULTIPROCESSING', '0')):
import multiprocessing
max_workers = get_num_cores()
global multiprocessing_pool
if not multiprocessing_pool:
multiprocessing_pool = multiprocessing.Pool(processes=get_num_cores())
if WINDOWS:
# Fix for python < 3.8 on windows. See: https://github.com/python/cpython/pull/13132
max_workers = min(max_workers, 61)
multiprocessing_pool = multiprocessing.Pool(processes=max_workers)
return multiprocessing_pool.map(mp_run_process, [(cmd, env, route_stdout_to_temp_files_suffix, pipe_stdout, check, cwd) for cmd in commands], chunksize=1)

std_outs = []
Expand Down