[issue14206] multiprocessing.Queue documentation is lacking important details
New submission from Garrett Moore <garrettmoore@gmail.com>: 1) If cancel_join_thread() is called, data may be lost. This is not explicitly stated. I had multiple writers put() data in a Queue, and wanted to have the workers finish before I began consuming the data. This caused a deadlock because my Queue was not empty, and it seemed like the a way to force my workers finish was to use cancel_join_thread(). This caused data loss. 2) multiprocessing.Queue states "The Queue class is a near clone of Queue.Queue." Queue.Queue states "If maxsize is less than or equal to zero, the queue size is infinite." mp.Queue provides no information on queue size. It is reasonable to assume then that it inherits the property of Queue.Queue. After discussion on IRC, it seems that mp.Queue maximum size is implementation-dependent and likely relies on how much data Pipes can hold on your platform. If this is the case there should be some mention of the fact that mp.Queue does NOT function like Queue.Queue does for maximum size. ---------- assignee: docs@python components: Documentation messages: 154995 nosy: Garrett.Moore, docs@python priority: normal severity: normal status: open title: multiprocessing.Queue documentation is lacking important details versions: Python 2.6, Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14206> _______________________________________
sbt <shibturn@gmail.com> added the comment: What you were told on IRC was wrong. By default the queue *does* have infinite size. When a process puts an item on the queue for the first time, a background thread is started which is responsible for writing items to the underlying pipe. This does mean that, on exit, the process should wait for the background thread to flush all the data to the pipe. This happens automatically unless you specifically prevent it by calling cancel_join_thread() method. If you stick to those methods supported by standard queue objects, then things should work correctly. (Maybe cancel_join_thread() would be better named allow_exit_without_flush().) ---------- nosy: +sbt _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14206> _______________________________________
Roundup Robot added the comment: New changeset f35401dba89f by Richard Oudkerk in branch '2.7': Issue #14206: Clarify docs for Queue.join_cancel_thread(). http://hg.python.org/cpython/rev/f35401dba89f New changeset 9746f217a270 by Richard Oudkerk in branch '3.3': Issue #14206: Clarify docs for Queue.join_cancel_thread(). http://hg.python.org/cpython/rev/9746f217a270 New changeset d0b48efac9de by Richard Oudkerk in branch 'default': Issue #14206: Clarify docs for Queue.join_cancel_thread(). http://hg.python.org/cpython/rev/d0b48efac9de ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14206> _______________________________________
Changes by Richard Oudkerk <shibturn@gmail.com>: ---------- resolution: -> fixed stage: -> committed/rejected _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14206> _______________________________________
Changes by Richard Oudkerk <shibturn@gmail.com>: ---------- status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14206> _______________________________________
participants (4)
-
Garrett Moore
-
Richard Oudkerk
-
Roundup Robot
-
sbt