Skip to content

Commit e0643d9

Browse files
[3.13] gh-73159 Added clarifications in multiprocessing docs on that objects are pickled. (GH-121686) (#121727)
gh-73159 Added clarifications in multiprocessing docs on that objects are pickled. (GH-121686) Added explicit comments about that objects are pickled when transmitted via multiprocessing queues and pipes. (cherry picked from commit b580589) Co-authored-by: Ulrik Södergren <[email protected]>
1 parent f78e1aa commit e0643d9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Doc/library/multiprocessing.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ processes:
254254
p.join()
255255

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

258259
**Pipes**
259260

@@ -281,6 +282,8 @@ processes:
281282
of corruption from processes using different ends of the pipe at the same
282283
time.
283284

285+
The :meth:`~Connection.send` method serializes the the object and
286+
:meth:`~Connection.recv` re-creates the object.
284287

285288
Synchronization between processes
286289
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -745,6 +748,11 @@ If you use :class:`JoinableQueue` then you **must** call
745748
semaphore used to count the number of unfinished tasks may eventually overflow,
746749
raising an exception.
747750

751+
One difference from other Python queue implementations, is that :mod:`multiprocessing`
752+
queues serializes all objects that are put into them using :mod:`pickle`.
753+
The object return by the get method is a re-created object that does not share memory
754+
with the original object.
755+
748756
Note that one can also create a shared queue by using a manager object -- see
749757
:ref:`multiprocessing-managers`.
750758

@@ -811,6 +819,8 @@ For an example of the usage of queues for interprocess communication see
811819
used for receiving messages and ``conn2`` can only be used for sending
812820
messages.
813821

822+
The :meth:`~multiprocessing.Connection.send` method serializes the the object using
823+
:mod:`pickle` and the :meth:`~multiprocessing.Connection.recv` re-creates the object.
814824

815825
.. class:: Queue([maxsize])
816826

0 commit comments

Comments
 (0)