]> granicus.if.org Git - python/commitdiff
bpo-33725: multiprocessing uses spawn by default on macOS (GH-13603)
authorVictor Stinner <vstinner@redhat.com>
Tue, 28 May 2019 14:02:50 +0000 (16:02 +0200)
committerGitHub <noreply@github.com>
Tue, 28 May 2019 14:02:50 +0000 (16:02 +0200)
On macOS, the multiprocessing module now uses the "spawn" start
method by default.

Doc/library/multiprocessing.rst
Doc/whatsnew/3.8.rst
Lib/multiprocessing/context.py
Misc/NEWS.d/next/Library/2019-05-28-01-17-42.bpo-33725.fFZoDG.rst [new file with mode: 0644]

index cc6dd4e9d702262d7f7fe88b4bd70d2d756e56e7..a4771d3a84cd40925f2729a3049c844243284ce6 100644 (file)
@@ -102,7 +102,7 @@ to start a process.  These *start methods* are
     will not be inherited.  Starting a process using this method is
     rather slow compared to using *fork* or *forkserver*.
 
-    Available on Unix and Windows.  The default on Windows.
+    Available on Unix and Windows.  The default on Windows and macOS.
 
   *fork*
     The parent process uses :func:`os.fork` to fork the Python
@@ -124,6 +124,11 @@ to start a process.  These *start methods* are
     Available on Unix platforms which support passing file descriptors
     over Unix pipes.
 
+.. versionchanged:: 3.8
+
+   On macOS, *spawn* start method is now the default: *fork* start method is no
+   longer reliable on macOS, see :issue:`33725`.
+
 .. versionchanged:: 3.4
    *spawn* added on all unix platforms, and *forkserver* added for
    some unix platforms.
index 860d6cc18f1152c7d8642f86dc1d1d344277027c..547e795d85fb1e3b6ecb19f7bba888400e7b6490 100644 (file)
@@ -469,6 +469,16 @@ access the ``madvise()`` system call.
 (Contributed by Zackery Spytz in :issue:`32941`.)
 
 
+multiprocessing
+---------------
+
+Added new :mod:`multiprocessing.shared_memory` module.
+(Contributed Davin Potts in :issue:`35813`.)
+
+On macOS, the *spawn* start method is now used by default.
+(Contributed by Victor Stinner in :issue:`33725`.)
+
+
 os
 --
 
index 5a4865751c22724a2ff2887fe2723e187959ea42..5f8e0f0cd46585cad1ee4aa936f5f018eccd3f40 100644 (file)
@@ -309,7 +309,12 @@ if sys.platform != 'win32':
         'spawn': SpawnContext(),
         'forkserver': ForkServerContext(),
     }
-    _default_context = DefaultContext(_concrete_contexts['fork'])
+    if sys.platform == 'darwin':
+        # bpo-33725: running arbitrary code after fork() is no longer reliable
+        # on macOS since macOS 10.14 (Mojave). Use spawn by default instead.
+        _default_context = DefaultContext(_concrete_contexts['spawn'])
+    else:
+        _default_context = DefaultContext(_concrete_contexts['fork'])
 
 else:
 
diff --git a/Misc/NEWS.d/next/Library/2019-05-28-01-17-42.bpo-33725.fFZoDG.rst b/Misc/NEWS.d/next/Library/2019-05-28-01-17-42.bpo-33725.fFZoDG.rst
new file mode 100644 (file)
index 0000000..6f1665f
--- /dev/null
@@ -0,0 +1,2 @@
+On macOS, the :mod:`multiprocessing` module now uses *spawn* start method by
+default.