{"record":{"id":"11b7d509991059ba","repo":"aio-libs/aiohttp","slug":"named-pipes-only-available-in-proactor-loop-under","errorCode":null,"errorMessage":"Named Pipes only available in proactor loop under windows","messagePattern":"Named Pipes only available in proactor loop under windows","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"aiohttp/connector.py","lineNumber":1756,"sourceCode":"    def __init__(\n        self,\n        path: str,\n        force_close: bool = False,\n        keepalive_timeout: _SENTINEL | float | None = sentinel,\n        limit: int = 100,\n        limit_per_host: int = 0,\n    ) -> None:\n        super().__init__(\n            force_close=force_close,\n            keepalive_timeout=keepalive_timeout,\n            limit=limit,\n            limit_per_host=limit_per_host,\n        )\n        if not isinstance(\n            self._loop,\n            asyncio.ProactorEventLoop,  # type: ignore[attr-defined]\n        ):\n            raise RuntimeError(\n                \"Named Pipes only available in proactor loop under windows\"\n            )\n        self._path = path\n\n    @property\n    def path(self) -> str:\n        \"\"\"Path to the named pipe.\"\"\"\n        return self._path\n\n    async def _create_connection(\n        self, req: ClientRequest, traces: list[\"Trace\"], timeout: \"ClientTimeout\"\n    ) -> ResponseHandler:\n        try:\n            async with ceil_timeout(\n                timeout.sock_connect, ceil_threshold=timeout.ceil_threshold\n            ):\n                _, proto = await self._loop.create_pipe_connection(  # type: ignore[attr-defined]\n                    self._factory, self._path","sourceCodeStart":1738,"sourceCodeEnd":1774,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/d041d4d0fd48c3f0832084d33be16cf1c4835f85/aiohttp/connector.py#L1738-L1774","documentation":"NamedPipeConnector.__init__ raises RuntimeError if the active event loop is not asyncio.ProactorEventLoop. Named pipes are a Windows-only IPC mechanism requiring the proactor event loop, which is the default on Windows but does not exist on Linux or macOS (which use SelectorEventLoop).","triggerScenarios":"Instantiating NamedPipeConnector on Linux, macOS, or any platform whose event loop is not ProactorEventLoop. Also triggered on Windows if a custom SelectorEventLoop was explicitly installed via WindowsSelectorEventLoopPolicy.","commonSituations":"Running Windows-only named pipe code on a Linux CI runner; testing npipe-based code on a macOS dev machine; explicitly setting asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) on Windows for compatibility with older libraries.","solutions":["On Linux/macOS use UnixConnector with a Unix domain socket instead","On Windows ensure the proactor loop is active: asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())","Gate by platform before instantiating: if sys.platform == 'win32': ... else use an alternative connector"],"exampleFix":"# before (crashes on Linux/macOS)\nconnector = NamedPipeConnector(path=r'\\\\.\\pipe\\mypipe')\n\n# after\nimport sys\nif sys.platform == 'win32':\n    asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())\n    connector = NamedPipeConnector(path=r'\\\\.\\pipe\\mypipe')\nelse:\n    connector = UnixConnector(path='/tmp/mypipe.sock')","handlingStrategy":"validation","validationCode":"import sys, asyncio\nif sys.platform != 'win32':\n    raise RuntimeError('NamedPipeConnector requires Windows')\nif not isinstance(asyncio.get_event_loop(), asyncio.ProactorEventLoop):\n    raise RuntimeError('NamedPipeConnector requires ProactorEventLoop')\n# safe to instantiate","typeGuard":null,"tryCatchPattern":"try:\n    connector = NamedPipeConnector(path=pipe_path)\nexcept RuntimeError as e:\n    if 'proactor' in str(e).lower():\n        logger.error('NamedPipeConnector not supported on this platform/loop')\n    raise","preventionTips":["Detect the platform before choosing a connector type","Document NamedPipeConnector as Windows-only in module docstrings","Run platform-specific integration tests only on matching CI runners"],"tags":["platform","windows","named-pipe","connector","event-loop"],"backgroundTag":null,"analyzedSha":"d041d4d0fd48c3f0832084d33be16cf1c4835f85","analyzedAt":"2026-08-11T20:44:15.550Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}