Skip to content
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

Add check before setting multiprocessing context to prevent the RuntimeError #4620

Merged
merged 3 commits into from
Aug 20, 2024
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
9 changes: 7 additions & 2 deletions pycbc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ def makedir(path):
# preserve common state information which we have relied on when using
# multiprocessing based pools.
import multiprocessing
if hasattr(multiprocessing, 'set_start_method'):
multiprocessing.set_start_method('fork')
if multiprocessing.get_start_method(allow_none=True) is None:
if hasattr(multiprocessing, 'set_start_method'):
multiprocessing.set_start_method('fork')
elif multiprocessing.get_start_method() != 'fork':
warnings.warn("PyCBC requires the use of the 'fork' start method"
" for multiprocessing, it is currently set to {}"
.format(multiprocessing.get_start_method()))
else:
HAVE_OMP = True

Expand Down
Loading