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

idomic webhook-mailer at python.org
Tue May 26 10:54:29 EDT 2020


https://github.com/python/cpython/commit/db098bc1f05bd0773943e59f83489f05f28dedf8
commit: db098bc1f05bd0773943e59f83489f05f28dedf8
branch: master
author: idomic <michael.ido at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-05-26T17:54:21+03:00
summary:

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

files:
A Misc/NEWS.d/next/Library/2020-02-23-15-09-47.bpo-39244.aBK5IM.rst
M Lib/multiprocessing/context.py
M Lib/test/_test_multiprocessing.py

diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py
index 5f8e0f0cd4658..8d0525d5d6217 100644
--- a/Lib/multiprocessing/context.py
+++ b/Lib/multiprocessing/context.py
@@ -257,10 +257,11 @@ def get_all_start_methods(self):
         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 dc8164f3288e1..155a8276e7507 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -5039,7 +5039,9 @@ def test_get_all(self):
             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 0000000000000..c7d8e0de676b5
--- /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.



More information about the Python-checkins mailing list