diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst index 48e027152a9851..252344df66cef3 100644 --- a/Doc/library/concurrent.futures.rst +++ b/Doc/library/concurrent.futures.rst @@ -412,7 +412,8 @@ to a :class:`ProcessPoolExecutor` will result in deadlock. .. versionchanged:: 3.14 The default process start method (see :ref:`multiprocessing-start-methods`) changed away from *fork*. If you - require the *fork* start method for :class:`ProcessPoolExecutor` you must + require the *fork* start method for :class:`ProcessPoolExecutor` or need to run + :ref:`unpicklable functions `, you must explicitly pass ``mp_context=multiprocessing.get_context("fork")``. .. _processpoolexecutor-example: diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 036b8f44b9ff3b..24267c6b16cc75 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -115,6 +115,8 @@ 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*. + Functions run with this method must be :ref:`picklable `. + Available on POSIX and Windows platforms. The default on Windows and macOS. *fork* @@ -124,6 +126,9 @@ to start a process. These *start methods* are inherited by the child process. Note that safely forking a multithreaded process is problematic. + Functions run with this method do *not* need to be + :ref:`picklable `. + Available on POSIX systems. .. versionchanged:: 3.14 @@ -146,6 +151,8 @@ to start a process. These *start methods* are side-effect so it is generally safe for it to use :func:`os.fork`. No unnecessary resources are inherited. + Functions run with this method must be :ref:`picklable `. + Available on POSIX platforms which support passing file descriptors over Unix pipes such as Linux. The default on those. diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index a6f595ccf08bf4..f9ef603b84b24f 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -487,14 +487,6 @@ Deprecated arguments are parsed. (Contributed by Serhiy Storchaka in :gh:`58032`.) -* :mod:`multiprocessing` and :mod:`concurrent.futures`: - The default start method (see :ref:`multiprocessing-start-methods`) changed - away from *fork* to *forkserver* on platforms where it was not already - *spawn* (Windows & macOS). If you require the threading incompatible *fork* - start method you must explicitly specify it when using :mod:`multiprocessing` - or :mod:`concurrent.futures` APIs. - (Contributed by Gregory P. Smith in :gh:`84559`.) - * :mod:`os`: :term:`Soft deprecate ` :func:`os.popen` and :func:`os.spawn* ` functions. They should no longer be used to @@ -661,6 +653,8 @@ Others :meth:`~object.__index__`. (Contributed by Mark Dickinson in :gh:`119743`.) +.. _whatsnew314-porting-to-python314: + Porting to Python 3.14 ====================== @@ -679,6 +673,19 @@ Changes in the Python API This temporary change affects other threads. (Contributed by Serhiy Storchaka in :gh:`69998`.) +* :mod:`multiprocessing` and :mod:`concurrent.futures`: + The default start method (see :ref:`multiprocessing-start-methods`) changed + away from *fork* to *forkserver* on POSIX platforms which support passing file + descriptors over Unix pipes, such as Linux. Windows and macOS keep *spawn* + as their default method. + If you require the threading-incompatible *fork* start method, + which can run :ref:`unpicklable functions `, + you must explicitly specify it when using :mod:`multiprocessing` + or :mod:`concurrent.futures` APIs. + Code running picklable functions on these platforms without explicitly opting + into the *fork* method will now raise :exc:`pickle.PicklingError`. + (Contributed by Gregory P. Smith in :gh:`84559`.) + Build changes =============