From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 26 May 2020 15:13:59 +0000 (-0700) Subject: bpo-39244: multiprocessing return default start method first on macOS (GH-18625) X-Git-Tag: v3.8.4rc1~87 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=285ff63351bb5a42099527c283f65434e761be83;p=thirdparty%2FPython%2Fcpython.git bpo-39244: multiprocessing return default start method first on macOS (GH-18625) (cherry picked from commit db098bc1f05bd0773943e59f83489f05f28dedf8) Co-authored-by: idomic --- diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py index 5f8e0f0cd465..8d0525d5d621 100644 --- a/Lib/multiprocessing/context.py +++ b/Lib/multiprocessing/context.py @@ -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 diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index ff58481f0031..d5cccac16f45 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -5007,7 +5007,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': diff --git a/Misc/NEWS.d/next/Library/2020-02-23-15-09-47.bpo-39244.aBK5IM.rst b/Misc/NEWS.d/next/Library/2020-02-23-15-09-47.bpo-39244.aBK5IM.rst new file mode 100644 index 000000000000..c7d8e0de676b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-02-23-15-09-47.bpo-39244.aBK5IM.rst @@ -0,0 +1,2 @@ +Fixed :class:`multiprocessing.context.get_all_start_methods` +to properly return the default method first on macOS.