diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 96e0dc831b7956..0bd1bf386ab8fa 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -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.7.4 + + 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. diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py index c98ee434249037..29639dd880ce64 100644 --- a/Lib/multiprocessing/context.py +++ b/Lib/multiprocessing/context.py @@ -310,7 +310,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: 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 index 00000000000000..6f1665f6fab328 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-05-28-01-17-42.bpo-33725.fFZoDG.rst @@ -0,0 +1,2 @@ +On macOS, the :mod:`multiprocessing` module now uses *spawn* start method by +default.