8000 gh-84559: Change the multiprocessing start method default to `forkserver` by gpshead · Pull Request #101556 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-84559: Change the multiprocessing start method default to forkserver #101556

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 14 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
simplify the default selection logic.
  • Loading branch information
gpshead committed Sep 26, 2024
commit 823ec3507f6a6415fa66b5e57b28ebb654b606cd
21 changes: 9 additions & 12 deletions Lib/multiprocessing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ def get_all_start_methods(self):
"""Returns a list of the supported start methods, default first."""
default = self._default_context.get_start_method()
start_method_names = [default]
start_method_names += (
name for name in _concrete_contexts if name != default
start_method_names.extend(
name for name in _concrete_contexts if name != default
)
return start_method_names

Expand Down Expand Up @@ -319,18 +319,15 @@ def _check_available(self):
'spawn': SpawnContext(),
'forkserver': ForkServerContext(),
}
if sys.platform == 'darwin':
# bpo-33725: running arbitrary code after fork() is no longer reliable
# on macOS since macOS 10.14 (Mojave). Use spawn by default instead.
_default_context = DefaultContext(_concrete_contexts['spawn'])
# bpo-33725: running arbitrary code after fork() is no longer reliable
# on macOS since macOS 10.14 (Mojave). Use spawn by default instead.
# gh-84559: We changed everyones default to a thread safeish one in 3.14.
if reduction.HAVE_SEND_HANDLE and sys.platform != 'darwin':
_default_context = DefaultContext(_concrete_contexts['forkserver'])
else:
# gh-84559: We changed the default to a thread safe one in 3.14.
if reduction.HAVE_SEND_HANDLE:
_default_context = DefaultContext(_concrete_contexts['forkserver'])
else:
_default_context = DefaultContext(_concrete_contexts['spawn'])
_default_context = DefaultContext(_concrete_contexts['spawn'])

else:
else: # Windows

class SpawnProcess(process.BaseProcess):
_start_method = 'spawn'
Expand Down
Loading
0