Skip to content

Commit

Permalink
simplify the default selection logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
gpshead committed Sep 26, 2024
1 parent 21f828f commit 823ec35
Showing 1 changed file with 9 additions and 12 deletions.
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

0 comments on commit 823ec35

Please sign in to comment.