Skip to content

gh-73159 Added clarifications in multiprocessing docs on that objects are pickled. #121686

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

Merged
merged 3 commits into from
Jul 13, 2024
Merged
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
10 changes: 10 additions & 0 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
p.join()

Queues are thread and process safe.
Any object put into a :mod:`~multiprocessing` queue will be serialized.

**Pipes**

Expand Down Expand Up @@ -281,6 +282,8 @@
of corruption from processes using different ends of the pipe at the same
time.

The :meth:`~Connection.send` method serializes the the object and

Check warning on line 285 in Doc/library/multiprocessing.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:meth reference target not found: Connection.send

Check warning on line 285 in Doc/library/multiprocessing.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:meth reference target not found: Connection.recv
:meth:`~Connection.recv` re-creates the object.

Synchronization between processes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -745,6 +748,11 @@
semaphore used to count the number of unfinished tasks may eventually overflow,
raising an exception.

One difference from other Python queue implementations, is that :mod:`multiprocessing`
queues serializes all objects that are put into them using :mod:`pickle`.
The object return by the get method is a re-created object that does not share memory
with the original object.

Note that one can also create a shared queue by using a manager object -- see
:ref:`multiprocessing-managers`.

Expand Down Expand Up @@ -811,6 +819,8 @@
used for receiving messages and ``conn2`` can only be used for sending
messages.

The :meth:`~multiprocessing.Connection.send` method serializes the the object using

Check warning on line 822 in Doc/library/multiprocessing.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:meth reference target not found: multiprocessing.Connection.send

Check warning on line 822 in Doc/library/multiprocessing.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:meth reference target not found: multiprocessing.Connection.recv
:mod:`pickle` and the :meth:`~multiprocessing.Connection.recv` re-creates the object.

.. class:: Queue([maxsize])

Expand Down
Loading