Skip to content

Commit b8c313a

Browse files
picnixzgpsheadStanFromIreland
authored
gh-84559: improve What's New entry for multiprocessing start method changes (#128173)
Co-authored-by: Gregory P. Smith <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]>
1 parent 5ec4bf8 commit b8c313a

File tree

2 files changed

+63
-12
lines changed

2 files changed

+63
-12
lines changed

Doc/library/multiprocessing.rst

+9
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ Contexts and start methods
107107
Depending on the platform, :mod:`multiprocessing` supports three ways
108108
to start a process. These *start methods* are
109109

110+
.. _multiprocessing-start-method-spawn:
111+
110112
*spawn*
111113
The parent process starts a fresh Python interpreter process. The
112114
child process will only inherit those resources necessary to run
@@ -117,6 +119,8 @@ to start a process. These *start methods* are
117119

118120
Available on POSIX and Windows platforms. The default on Windows and macOS.
119121

122+
.. _multiprocessing-start-method-fork:
123+
120124
*fork*
121125
The parent process uses :func:`os.fork` to fork the Python
122126
interpreter. The child process, when it begins, is effectively
@@ -137,6 +141,8 @@ to start a process. These *start methods* are
137141
raise a :exc:`DeprecationWarning`. Use a different start method.
138142
See the :func:`os.fork` documentation for further explanation.
139143

144+
.. _multiprocessing-start-method-forkserver:
145+
140146
*forkserver*
141147
When the program starts and selects the *forkserver* start method,
142148
a server process is spawned. From then on, whenever a new process
@@ -2987,6 +2993,9 @@ Beware of replacing :data:`sys.stdin` with a "file like object"
29872993

29882994
For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331`
29892995

2996+
.. _multiprocessing-programming-spawn:
2997+
.. _multiprocessing-programming-forkserver:
2998+
29902999
The *spawn* and *forkserver* start methods
29913000
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29923001

Doc/whatsnew/3.14.rst

+54-12
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ Summary -- release highlights
7070
* :ref:`A new type of interpreter <whatsnew314-tail-call>`
7171

7272

73+
Incompatible changes
74+
====================
75+
76+
On platforms other than macOS and Windows, the default :ref:`start
77+
method <multiprocessing-start-methods>` for :mod:`multiprocessing`
78+
and :class:`~concurrent.futures.ProcessPoolExecutor` switches from
79+
*fork* to *forkserver*.
80+
81+
See :ref:`(1) <whatsnew314-concurrent-futures-start-method>` and
82+
:ref:`(2) <whatsnew314-multiprocessing-start-method>` for details.
83+
84+
If you encounter :exc:`NameError`\s or pickling errors coming out of
85+
:mod:`multiprocessing` or :mod:`concurrent.futures`, see the
86+
:ref:`forkserver restrictions <multiprocessing-programming-forkserver>`.
87+
88+
7389
New features
7490
============
7591

@@ -396,12 +412,26 @@ concurrent.futures
396412
same process) to Python code. This is separate from the proposed API
397413
in :pep:`734`.
398414
(Contributed by Eric Snow in :gh:`124548`.)
399-
* The default ``ProcessPoolExecutor`` start method (see
400-
:ref:`multiprocessing-start-methods`) changed from *fork* to *forkserver* on
401-
platforms other than macOS & Windows. If you require the threading
402-
incompatible *fork* start method you must explicitly request it by
403-
supplying a *mp_context* to :class:`concurrent.futures.ProcessPoolExecutor`.
404-
(Contributed by Gregory P. Smith in :gh:`84559`.)
415+
416+
.. _whatsnew314-concurrent-futures-start-method:
417+
418+
* The default :class:`~concurrent.futures.ProcessPoolExecutor`
419+
:ref:`start method <multiprocessing-start-methods>` changed
420+
from :ref:`fork <multiprocessing-start-method-fork>` to :ref:`forkserver
421+
<multiprocessing-start-method-forkserver>` on platforms other than macOS and
422+
Windows where it was already :ref:`spawn <multiprocessing-start-method-spawn>`.
423+
424+
If the threading incompatible *fork* method is required, you must explicitly
425+
request it by supplying a multiprocessing context *mp_context* to
426+
:class:`~concurrent.futures.ProcessPoolExecutor`.
427+
428+
See :ref:`forkserver restrictions <multiprocessing-programming-forkserver>`
429+
for information and differences with the *fork* method and how this change
430+
may affect existing code with mutable global shared variables and/or shared
431+
objects that can not be automatically :mod:`pickled <pickle>`.
432+
433+
(Contributed by Gregory P. Smith in :gh:`84559`.)
434+
405435

406436
contextvars
407437
-----------
@@ -637,18 +667,30 @@ mimetypes
637667
multiprocessing
638668
---------------
639669

640-
* The default start method (see :ref:`multiprocessing-start-methods`) changed
641-
from *fork* to *forkserver* on platforms other than macOS & Windows where
642-
it was already *spawn*. If you require the threading incompatible *fork*
643-
start method you must explicitly request it using a context from
644-
:func:`multiprocessing.get_context` (preferred) or change the default via
645-
:func:`multiprocessing.set_start_method`.
670+
.. _whatsnew314-multiprocessing-start-method:
671+
672+
* The default :ref:`start method <multiprocessing-start-methods>` changed
673+
from :ref:`fork <multiprocessing-start-method-fork>` to :ref:`forkserver
674+
<multiprocessing-start-method-forkserver>` on platforms other than macOS and
675+
Windows where it was already :ref:`spawn <multiprocessing-start-method-spawn>`.
676+
677+
If the threading incompatible *fork* method is required, you must explicitly
678+
request it via a context from :func:`multiprocessing.get_context` (preferred)
679+
or change the default via :func:`multiprocessing.set_start_method`.
680+
681+
See :ref:`forkserver restrictions <multiprocessing-programming-forkserver>`
682+
for information and differences with the *fork* method and how this change
683+
may affect existing code with mutable global shared variables and/or shared
684+
objects that can not be automatically :mod:`pickled <pickle>`.
685+
646686
(Contributed by Gregory P. Smith in :gh:`84559`.)
687+
647688
* :mod:`multiprocessing`'s ``"forkserver"`` start method now authenticates
648689
its control socket to avoid solely relying on filesystem permissions
649690
to restrict what other processes could cause the forkserver to spawn workers
650691
and run code.
651692
(Contributed by Gregory P. Smith for :gh:`97514`.)
693+
652694
* The :ref:`multiprocessing proxy objects <multiprocessing-proxy_objects>`
653695
for *list* and *dict* types gain previously overlooked missing methods:
654696

0 commit comments

Comments
 (0)