-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
[doc] The fact that multiprocess.Queue uses serialization should be documented. #73159
Comments
When I did some tests involving unittest.mock.sentinel and multiprocessing.Queue, I noticed that multiprocessing.Queue changes the id of the sentinel. This behaviour is definitely surprising and not documented. |
See http://stackoverflow.com/a/925241/5069869 Apparently multiprocessing.Queue uses pickle to serialize the objects in the queue, which explains the change of identity, but is absolutely unclear from the documentation. |
That fact that this is so is implicit in the name multi*process*ing and Should we document this explicitly? Perhaps so. Maybe in the multiprocessing introduction? |
My first thought was that Queue was implemented using shared memory. So I guess some clarification in the documentation would be helpful. |
Yeah, that's why I said "in the general case". Making it clear in the overview seems reasonable to me. |
All communication between processes in multiprocessing has consistently used pickle to serialize the data being communicated (this includes what is described in the "Shared memory" section of the docs). The documentation has not done a great job of making this clear, instead only describing the requirement that data be pickleable in select places. For example, in the section on Queues: Though it only applies to 3.6+, bpo-28053 still needs its own documentation improvement to make clear that the mechanism for communicating data defaults to serialization by pickle but that this can be replaced by alternatives. I agree that the documentation around the use of pickle in multiprocessing deserves improvement. |
There is a note mentioning pickle in this section: https://docs.python.org/3/library/multiprocessing.html#pipes-and-queues It starts with "When an object is put on a queue, the object is pickled and..." A comment about the object ids can be added there. |
Mentioning ids would be pretty much redundant with mentioning pickle. If it is pickled its id is going to change. I think Davin was suggesting that while the use of serialization is documented, it is not documented *consistently*. Everywhere serialization happens it should be mentioned in the docs. Regardless, a proposed doc PR is the way forward here. |
I am starting a doc PR on this during this weekends EuroPython Sprints and plan to have it finished by this weekend |
… are pickled. (GH-121686) Added explicit comments about that objects are pickled when transmitted via multiprocessing queues and pipes.
…bjects are pickled. (pythonGH-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]>
…bjects are pickled. (pythonGH-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]>
thanks! there might be seen as adding some redundancy in the multiprocessing docs, but that's a larger "should this doc be rewritten from a different perspective?" kind of issue. This new text at least gets the important information stated directly, in the places I expect readers are likely to see it. Rather than inferring it from other notes in the docs. |
…objects are pickled. (GH-121686) (#121728) 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]>
…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]>
…bjects are pickled. (pythonGH-121686) Added explicit comments about that objects are pickled when transmitted via multiprocessing queues and pipes.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: