]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39244: multiprocessing return default start method first on macOS (GH-18625)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 26 May 2020 15:13:59 +0000 (08:13 -0700)
committerGitHub <noreply@github.com>
Tue, 26 May 2020 15:13:59 +0000 (08:13 -0700)
(cherry picked from commit db098bc1f05bd0773943e59f83489f05f28dedf8)

Co-authored-by: idomic <michael.ido@gmail.com>
Lib/multiprocessing/context.py
Lib/test/_test_multiprocessing.py
Misc/NEWS.d/next/Library/2020-02-23-15-09-47.bpo-39244.aBK5IM.rst [new file with mode: 0644]

index 5f8e0f0cd46585cad1ee4aa936f5f018eccd3f40..8d0525d5d62179b0ac6d8ca16231f8d428ff44b3 100644 (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
index ff58481f00314d1dc08f84b7c46db17fe01948f3..d5cccac16f451736929c19d3fd9502c49f78864e 100644 (file)
@@ -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 (file)
index 0000000..c7d8e0d
--- /dev/null
@@ -0,0 +1,2 @@
+Fixed :class:`multiprocessing.context.get_all_start_methods`\r
+to properly return the default method first on macOS.\r