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

gh-84559: improve What's New entry for multiprocessing start method changes #128173

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
9 changes: 9 additions & 0 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ Contexts and start methods
Depending on the platform, :mod:`multiprocessing` supports three ways
to start a process. These *start methods* are

.. _multiprocessing-start-method-spawn:

*spawn*
The parent process starts a fresh Python interpreter process. The
child process will only inherit those resources necessary to run
Expand All @@ -117,6 +119,8 @@ to start a process. These *start methods* are

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

.. _multiprocessing-start-method-fork:

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

.. _multiprocessing-start-method-forkserver:

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

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

.. _multiprocessing-programming-spawn:
.. _multiprocessing-programming-forkserver:

The *spawn* and *forkserver* start methods
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
20 changes: 15 additions & 5 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,27 @@ multiprocessing
---------------

* The default start method (see :ref:`multiprocessing-start-methods`) changed
from *fork* to *forkserver* on platforms other than macOS & Windows where
it was already *spawn*. If you require the threading incompatible *fork*
start method you must explicitly request it using a context from
:func:`multiprocessing.get_context` (preferred) or change the default via
:func:`multiprocessing.set_start_method`.
from :ref:`fork <multiprocessing-start-method-fork>` to :ref:`forkserver
<multiprocessing-start-method-forkserver>` on platforms other than macOS &
hugovk marked this conversation as resolved.
Show resolved Hide resolved
Windows where it was already :ref:`spawn <multiprocessing-start-method-spawn>`.

If the threading incompatible *fork* method is required, you must explicitly
request it via a context from :func:`multiprocessing.get_context` (preferred)
or change the default via :func:`multiprocessing.set_start_method`.

See :ref:`forkserver restrictions <multiprocessing-programming-forkserver>`
for information and differences with the *fork* method and how this change
may affect existing code with mutable global shared variables and/or shared
objects that can not be automatically :mod:`pickled <pickle>`.

(Contributed by Gregory P. Smith in :gh:`84559`.)

* :mod:`multiprocessing`'s ``"forkserver"`` start method now authenticates
its control socket to avoid solely relying on filesystem permissions
to restrict what other processes could cause the forkserver to spawn workers
and run code.
(Contributed by Gregory P. Smith for :gh:`97514`.)

* The :ref:`multiprocessing proxy objects <multiprocessing-proxy_objects>`
for *list* and *dict* types gain previously overlooked missing methods:

Expand Down
Loading