Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all
(self)
| 217 | return item |
| 218 | |
| 219 | def task_done(self): |
| 220 | """Indicate that a formerly enqueued task is complete. |
| 221 | |
| 222 | Used by queue consumers. For each get() used to fetch a task, |
| 223 | a subsequent call to task_done() tells the queue that the processing |
| 224 | on the task is complete. |
| 225 | |
| 226 | If a join() is currently blocking, it will resume when all items have |
| 227 | been processed (meaning that a task_done() call was received for every |
| 228 | item that had been put() into the queue). |
| 229 | |
| 230 | Raises ValueError if called more times than there were items placed in |
| 231 | the queue. |
| 232 | """ |
| 233 | if self._unfinished_tasks <= 0: |
| 234 | raise ValueError('task_done() called too many times') |
| 235 | self._unfinished_tasks -= 1 |
| 236 | if self._unfinished_tasks == 0: |
| 237 | self._finished.set() |
| 238 | |
| 239 | async def join(self): |
| 240 | """Block until all items in the queue have been gotten and processed. |