Description
Documentation
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Queue.close
It says "Indicate that no more data will be put on this queue by the current process." but that looks to only be half the story.
https://github.com/python/cpython/blob/main/Lib/multiprocessing/queues.py#L255
As I understand this is the implementation, which closes both the writing and reading ends of the pipe. As result, after close() not only can no more data be written, but also no more data can be read by the current process. A reader in a different process will be able to drain any buffered messages, but not in the current one.
For a writer and reader in the same process, an application-level protocol would be required to first stop writing, then signal the reader to drain everything and terminate (eg if it's a thread) and only then can the queue be closed.
If correct, this should be made explicit in the docs.
The documentation issue looks to not apply to multiprocessing.SimpleQueue.close() - this clearly says get() cannot be used on a closed queue.
The documentation issue looks to also not apply to JoinableQueue, as that clearly says it's a subclass of multiprocessing.Queue (so things like close() are not described separately).
Metadata
Metadata
Assignees
Projects
Status