mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-39244: multiprocessing return default start method first on macOS (GH-18625)
(cherry picked from commit db098bc1f0
)
Co-authored-by: idomic <michael.ido@gmail.com>
This commit is contained in:
parent
500cd89ecc
commit
1c88bf8541
3 changed files with 9 additions and 4 deletions
|
@ -257,10 +257,11 @@ class DefaultContext(BaseContext):
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return ['spawn']
|
return ['spawn']
|
||||||
else:
|
else:
|
||||||
|
methods = ['spawn', 'fork'] if sys.platform == 'darwin' else ['fork', 'spawn']
|
||||||
if reduction.HAVE_SEND_HANDLE:
|
if reduction.HAVE_SEND_HANDLE:
|
||||||
return ['fork', 'spawn', 'forkserver']
|
methods.append('forkserver')
|
||||||
else:
|
return methods
|
||||||
return ['fork', 'spawn']
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Context types for fixed start method
|
# Context types for fixed start method
|
||||||
|
|
|
@ -5039,7 +5039,9 @@ class TestStartMethod(unittest.TestCase):
|
||||||
self.assertEqual(methods, ['spawn'])
|
self.assertEqual(methods, ['spawn'])
|
||||||
else:
|
else:
|
||||||
self.assertTrue(methods == ['fork', 'spawn'] or
|
self.assertTrue(methods == ['fork', 'spawn'] or
|
||||||
methods == ['fork', 'spawn', 'forkserver'])
|
methods == ['spawn', 'fork'] or
|
||||||
|
methods == ['fork', 'spawn', 'forkserver'] or
|
||||||
|
methods == ['spawn', 'fork', 'forkserver'])
|
||||||
|
|
||||||
def test_preload_resources(self):
|
def test_preload_resources(self):
|
||||||
if multiprocessing.get_start_method() != 'forkserver':
|
if multiprocessing.get_start_method() != 'forkserver':
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fixed :class:`multiprocessing.context.get_all_start_methods`
|
||||||
|
to properly return the default method first on macOS.
|
Loading…
Add table
Add a link
Reference in a new issue