Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-33725: multiprocessing uses spawn by default on macOS #13603

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions Doc/whatsnew/3.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--

Expand Down
7 changes: 6 additions & 1 deletion Lib/multiprocessing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,12 @@ def _check_available(self):
'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:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
On macOS, the :mod:`multiprocessing` module now uses *spawn* start method by
default.