Issue 27747: Broken example in the queue module documentation (original) (raw)
Issue27747
Created on 2016-08-12 14:01 by Paulo Gabriel Poiati, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg272540 - (view) | Author: Paulo Gabriel Poiati (Paulo Gabriel Poiati) | Date: 2016-08-12 14:01 |
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. | ||
msg272542 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2016-08-12 14:42 |
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. | ||
msg272547 - (view) | Author: Paulo Gabriel Poiati (Paulo Gabriel Poiati) | Date: 2016-08-12 17:24 |
You are absolutely right David. I was calling join after putting `None` in the queue. Sorry, I'm closing this. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:34 | admin | set | github: 71934 |
2016-08-12 18:17:31 | r.david.murray | set | type: enhancement -> behaviorstage: resolved |
2016-08-12 17:24:36 | Paulo Gabriel Poiati | set | status: open -> closedresolution: not a bugmessages: + |
2016-08-12 14:42:52 | r.david.murray | set | nosy: + r.david.murraymessages: + |
2016-08-12 14:01:01 | Paulo Gabriel Poiati | create |