mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
bpo-33725: multiprocessing uses spawn by default on macOS (GH-13603)
On macOS, the multiprocessing module now uses the "spawn" start method by default.
This commit is contained in:
parent
a85a1d337d
commit
17a5588740
4 changed files with 24 additions and 2 deletions
|
|
@ -102,7 +102,7 @@ to start a process. These *start methods* are
|
||||||
will not be inherited. Starting a process using this method is
|
will not be inherited. Starting a process using this method is
|
||||||
rather slow compared to using *fork* or *forkserver*.
|
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*
|
*fork*
|
||||||
The parent process uses :func:`os.fork` to fork the Python
|
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
|
Available on Unix platforms which support passing file descriptors
|
||||||
over Unix pipes.
|
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
|
.. versionchanged:: 3.4
|
||||||
*spawn* added on all unix platforms, and *forkserver* added for
|
*spawn* added on all unix platforms, and *forkserver* added for
|
||||||
some unix platforms.
|
some unix platforms.
|
||||||
|
|
|
||||||
|
|
@ -469,6 +469,16 @@ access the ``madvise()`` system call.
|
||||||
(Contributed by Zackery Spytz in :issue:`32941`.)
|
(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
|
os
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,11 @@ if sys.platform != 'win32':
|
||||||
'spawn': SpawnContext(),
|
'spawn': SpawnContext(),
|
||||||
'forkserver': ForkServerContext(),
|
'forkserver': ForkServerContext(),
|
||||||
}
|
}
|
||||||
|
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'])
|
_default_context = DefaultContext(_concrete_contexts['fork'])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
On macOS, the :mod:`multiprocessing` module now uses *spawn* start method by
|
||||||
|
default.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue