Skip to content

Commit 823ec35

Browse files
committed
simplify the default selection logic.
1 parent 21f828f commit 823ec35

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

Lib/multiprocessing/context.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ def get_all_start_methods(self):
261261
"""Returns a list of the supported start methods, default first."""
262262
default = self._default_context.get_start_method()
263263
start_method_names = [default]
264-
start_method_names += (
265-
name for name in _concrete_contexts if name != default
264+
start_method_names.extend(
265+
name for name in _concrete_contexts if name != default
266266
)
267267
return start_method_names
268268

@@ -319,18 +319,15 @@ def _check_available(self):
319319
'spawn': SpawnContext(),
320320
'forkserver': ForkServerContext(),
321321
}
322-
if sys.platform == 'darwin':
323-
# bpo-33725: running arbitrary code after fork() is no longer reliable
324-
# on macOS since macOS 10.14 (Mojave). Use spawn by default instead.
325-
_default_context = DefaultContext(_concrete_contexts['spawn'])
322+
# bpo-33725: running arbitrary code after fork() is no longer reliable
323+
# on macOS since macOS 10.14 (Mojave). Use spawn by default instead.
324+
# gh-84559: We changed everyones default to a thread safeish one in 3.14.
325+
if reduction.HAVE_SEND_HANDLE and sys.platform != 'darwin':
326+
_default_context = DefaultContext(_concrete_contexts['forkserver'])
326327
else:
327-
# gh-84559: We changed the default to a thread safe one in 3.14.
328-
if reduction.HAVE_SEND_HANDLE:
329-
_default_context = DefaultContext(_concrete_contexts['forkserver'])
330-
else:
331-
_default_context = DefaultContext(_concrete_contexts['spawn'])
328+
_default_context = DefaultContext(_concrete_contexts['spawn'])
332329

333-
else:
330+
else: # Windows
334331

335332
class SpawnProcess(process.BaseProcess):
336333
_start_method = 'spawn'

0 commit comments

Comments
 (0)