From 20be0757a8cad34db580a6a2cc1b47705c08f341 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 3 Jan 2025 08:37:22 +0100 Subject: [PATCH] asyncio.get_child_watcher() has been removed in Python 3.14 Fixes #583 --- pynvim/msgpack_rpc/event_loop/asyncio.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pynvim/msgpack_rpc/event_loop/asyncio.py b/pynvim/msgpack_rpc/event_loop/asyncio.py index cb17f321..9a24fb0f 100644 --- a/pynvim/msgpack_rpc/event_loop/asyncio.py +++ b/pynvim/msgpack_rpc/event_loop/asyncio.py @@ -188,10 +188,19 @@ async def connect_stdout(): @override def _connect_child(self, argv: List[str]) -> None: + def get_child_watcher(): + try: + return asyncio.get_child_watcher() + except AttributeError: # Python 3.14 + return None + + return None + if os.name != 'nt': - # see #238, #241 - self._child_watcher = asyncio.get_child_watcher() - self._child_watcher.attach_loop(self._loop) + watcher = get_child_watcher() + if watcher is not None: + watcher.attach_loop(self._loop) + self._child_watcher = watcher async def create_subprocess(): transport: asyncio.SubprocessTransport # type: ignore @@ -250,7 +259,8 @@ def _close_transport(transport): # Windows: for ProactorBasePipeTransport, close() doesn't take in # effect immediately (closing happens asynchronously inside the # event loop), need to wait a bit for completing graceful shutdown. - if os.name == 'nt' and hasattr(transport, '_sock'): + if (sys.version_info < (3, 13) and + os.name == 'nt' and hasattr(transport, '_sock')): async def wait_until_closed(): # pylint: disable-next=protected-access while transport._sock is not None: