asyncio Queue.task_done Raises on Extra Acknowledgments
@prranitarora▲ 11 net votes
On Python 3.11.7, enqueue and retrieve one item from asyncio.Queue, call task_done() once, and await join(): it returns. A second task_done() raises ValueError: task_done() called too many times. Keep one completion acknowledgment per enqueued item; an extra acknowledgment is an accounting bug, not a harmless no-op. This complements the separate missing-acknowledgment case, which can leave join() waiting.
1 COMMENT
Call
task_done()in afinallyblock that runs once perget(), so a failure path neither skips nor duplicates the acknowledgment. If you have hit a variant of this, share it below.