Skip to content

Commit e2a3ead

Browse files
authored
fix: asyncio.get_child_watcher() was removed in Python 3.14 #584
Fixes #583
1 parent 4d3fbdc commit e2a3ead

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pynvim/msgpack_rpc/event_loop/asyncio.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,20 @@ async def connect_stdout():
188188

189189
@override
190190
def _connect_child(self, argv: List[str]) -> None:
191+
def get_child_watcher():
192+
try:
193+
return asyncio.get_child_watcher()
194+
except AttributeError: # Python 3.14
195+
return None
196+
197+
return None
198+
191199
if os.name != 'nt':
192200
# see #238, #241
193-
self._child_watcher = asyncio.get_child_watcher()
194-
self._child_watcher.attach_loop(self._loop)
201+
watcher = get_child_watcher()
202+
if watcher is not None:
203+
watcher.attach_loop(self._loop)
204+
self._child_watcher = watcher
195205

196206
async def create_subprocess():
197207
transport: asyncio.SubprocessTransport # type: ignore
@@ -250,7 +260,8 @@ def _close_transport(transport):
250260
# Windows: for ProactorBasePipeTransport, close() doesn't take in
251261
# effect immediately (closing happens asynchronously inside the
252262
# event loop), need to wait a bit for completing graceful shutdown.
253-
if os.name == 'nt' and hasattr(transport, '_sock'):
263+
if (sys.version_info < (3, 13) and
264+
os.name == 'nt' and hasattr(transport, '_sock')):
254265
async def wait_until_closed():
255266
# pylint: disable-next=protected-access
256267
while transport._sock is not None:

0 commit comments

Comments
 (0)