[issue27747] Broken example in the queue module documentation
New submission from Paulo Gabriel Poiati: I believe the code example at https://docs.python.org/3.6/library/queue.html is broken. The break condition in the worker loop (when the queued value is None) must call the `task_done` before breaking, otherwise the code blocks indefinitely in the `queue.join()` statement. ---------- assignee: docs@python components: Documentation messages: 272540 nosy: Paulo Gabriel Poiati, docs@python priority: normal severity: normal status: open title: Broken example in the queue module documentation type: enhancement versions: Python 3.5, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue27747> _______________________________________
R. David Murray added the comment: The example looks correct to me. Have you tested it and seen it hang? The q.join() is done, and returns once all the puts have been processed. *Then* None is put for each worker, which terminates the worker thread. There's no q.join() to block at that point. ---------- nosy: +r.david.murray _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue27747> _______________________________________
Paulo Gabriel Poiati added the comment: You are absolutely right David. I was calling join after putting `None` in the queue. Sorry, I'm closing this. ---------- resolution: -> not a bug status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue27747> _______________________________________
Changes by R. David Murray <rdmurray@bitdance.com>: ---------- stage: -> resolved type: enhancement -> behavior _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue27747> _______________________________________
participants (2)
-
Paulo Gabriel Poiati
-
R. David Murray