I'm using asyncio.Queue to store data. According to the docs, after each queue.get()
I should call queue.task_done()
. Why?
Asked
Active
Viewed 557 times
1

user3599803
- 6,435
- 17
- 69
- 130
-
"after each queue.get() I should call queue.task_done()" - when using that mechanism, you should call `task_done` *after the task is done*. This is technically after `queue.get()`, but not immediately after. – user2357112 Dec 13 '18 at 21:38
-
2You only need to call `task_done()` if you plan on calling `await queue.join()` to await the event when everything that was put in the queue has been processed. See e.g. [here](https://stackoverflow.com/a/52615705/1600898) for an example. – user4815162342 Dec 13 '18 at 21:44