Skip to content

Commit db098bc

Browse files
authored
bpo-39244: multiprocessing return default start method first on macOS (GH-18625)
1 parent 5eb45d7 commit db098bc

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Lib/multiprocessing/context.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,11 @@ def get_all_start_methods(self):
257257
if sys.platform == 'win32':
258258
return ['spawn']
259259
else:
260+
methods = ['spawn', 'fork'] if sys.platform == 'darwin' else ['fork', 'spawn']
260261
if reduction.HAVE_SEND_HANDLE:
261-
return ['fork', 'spawn', 'forkserver']
262-
else:
263-
return ['fork', 'spawn']
262+
methods.append('forkserver')
263+
return methods
264+
264265

265266
#
266267
# Context types for fixed start method

Lib/test/_test_multiprocessing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5039,7 +5039,9 @@ def test_get_all(self):
50395039
self.assertEqual(methods, ['spawn'])
50405040
else:
50415041
self.assertTrue(methods == ['fork', 'spawn'] or
5042-
methods == ['fork', 'spawn', 'forkserver'])
5042+
methods == ['spawn', 'fork'] or
5043+
methods == ['fork', 'spawn', 'forkserver'] or
5044+
methods == ['spawn', 'fork', 'forkserver'])
50435045

50445046
def test_preload_resources(self):
50455047
if multiprocessing.get_start_method() != 'forkserver':
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed :class:`multiprocessing.context.get_all_start_methods`
2+
to properly return the default method first on macOS.

0 commit comments

Comments
 (0)