bpo-39244: multiprocessing return default start method first on macOS (GH-18625)

This commit is contained in:
idomic 2020-05-26 10:54:21 -04:00 committed by GitHub
parent 5eb45d7d4e
commit db098bc1f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -257,10 +257,11 @@ class DefaultContext(BaseContext):
if sys.platform == 'win32':
return ['spawn']
else:
methods = ['spawn', 'fork'] if sys.platform == 'darwin' else ['fork', 'spawn']
if reduction.HAVE_SEND_HANDLE:
return ['fork', 'spawn', 'forkserver']
else:
return ['fork', 'spawn']
methods.append('forkserver')
return methods
#
# Context types for fixed start method

View File

@ -5039,7 +5039,9 @@ class TestStartMethod(unittest.TestCase):
self.assertEqual(methods, ['spawn'])
else:
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):
if multiprocessing.get_start_method() != 'forkserver':

View File

@ -0,0 +1,2 @@
Fixed :class:`multiprocessing.context.get_all_start_methods`
to properly return the default method first on macOS.