{"record":{"id":"29cced88242edd85","repo":"microsoft/autogen","slug":"self-r-is-bound-to-a-different-event-loop","errorCode":null,"errorMessage":"{self!r} is bound to a different event loop","messagePattern":"(.+?) is bound to a different event loop","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-core/src/autogen_core/_queue.py","lineNumber":24,"sourceCode":"import collections\nimport threading\nfrom typing import Generic, TypeVar\n\n_global_lock = threading.Lock()\n\n\nclass _LoopBoundMixin:\n    _loop = None\n\n    def _get_loop(self) -> asyncio.AbstractEventLoop:\n        loop = asyncio.get_running_loop()\n\n        if self._loop is None:\n            with _global_lock:\n                if self._loop is None:\n                    self._loop = loop\n        if loop is not self._loop:\n            raise RuntimeError(f\"{self!r} is bound to a different event loop\")\n        return loop\n\n\nclass QueueShutDown(Exception):\n    \"\"\"Raised when putting on to or getting from a shut-down Queue.\"\"\"\n\n    pass\n\n\nT = TypeVar(\"T\")\n\n\nclass Queue(_LoopBoundMixin, Generic[T]):\n    def __init__(self, maxsize: int = 0):\n        self._maxsize = maxsize\n        self._getters = collections.deque[asyncio.Future[None]]()\n        self._putters = collections.deque[asyncio.Future[None]]()\n        self._unfinished_tasks = 0","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-core/src/autogen_core/_queue.py#L6-L42","documentation":"Error \"{self!r} is bound to a different event loop\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at python/packages/autogen-core/src/autogen_core/_queue.py:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the queue on the same loop that consumes it"],"exampleFix":"Instantiate asyncio.Queue inside the running loop's context","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-15T17:31:12.345Z"}