{"record":{"id":"98e8f03b8cac5e32","repo":"microsoft/autogen","slug":"task-done-called-too-many-times","errorCode":null,"errorMessage":"task_done() called too many times","messagePattern":"task_done\\(\\) called too many times","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-core/src/autogen_core/_queue.py","lineNumber":222,"sourceCode":"    def task_done(self) -> None:\n        \"\"\"Indicate that a formerly enqueued task is complete.\n\n        Used by queue consumers. For each get() used to fetch a task,\n        a subsequent call to task_done() tells the queue that the processing\n        on the task is complete.\n\n        If a join() is currently blocking, it will resume when all items have\n        been processed (meaning that a task_done() call was received for every\n        item that had been put() into the queue).\n\n        shutdown(immediate=True) calls task_done() for each remaining item in\n        the queue.\n\n        Raises ValueError if called more times than there were items placed in\n        the queue.\n        \"\"\"\n        if self._unfinished_tasks <= 0:\n            raise ValueError(\"task_done() called too many times\")\n        self._unfinished_tasks -= 1\n        if self._unfinished_tasks == 0:\n            self._finished.set()\n\n    async def join(self) -> None:\n        \"\"\"Block until all items in the queue have been gotten and processed.\n\n        The count of unfinished tasks goes up whenever an item is added to the\n        queue. The count goes down whenever a consumer calls task_done() to\n        indicate that the item was retrieved and all work on it is complete.\n        When the count of unfinished tasks drops to zero, join() unblocks.\n        \"\"\"\n        if self._unfinished_tasks > 0:\n            await self._finished.wait()\n\n    def shutdown(self, immediate: bool = False) -> None:\n        \"\"\"Shut-down the queue, making queue gets and puts raise QueueShutDown.\n","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-core/src/autogen_core/_queue.py#L204-L240","documentation":"Error \"task_done() called too many times\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at python/packages/autogen-core/src/autogen_core/_queue.py:222 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pair each task_done() with a prior get()"],"exampleFix":"Call task_done() exactly once per dequeued item","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}