Skip to content

Commit 20be075

Browse files
committed
asyncio.get_child_watcher() has been removed in Python 3.14
Fixes #583
1 parent 4d3fbdc commit 20be075

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pynvim/msgpack_rpc/event_loop/asyncio.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,19 @@ 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':
192-
# see #238, #241
193-
self._child_watcher = asyncio.get_child_watcher()
194-
self._child_watcher.attach_loop(self._loop)
200+
watcher = get_child_watcher()
201+
if watcher is not None:
202+
watcher.attach_loop(self._loop)
203+
self._child_watcher = watcher
195204

196205
async def create_subprocess():
197206
transport: asyncio.SubprocessTransport # type: ignore
@@ -250,7 +259,8 @@ def _close_transport(transport):
250259
# Windows: for ProactorBasePipeTransport, close() doesn't take in
251260
# effect immediately (closing happens asynchronously inside the
252261
# event loop), need to wait a bit for completing graceful shutdown.
253-
if os.name == 'nt' and hasattr(transport, '_sock'):
262+
if (sys.version_info < (3, 13) and
263+
os.name == 'nt' and hasattr(transport, '_sock')):
254264
async def wait_until_closed():
255265
# pylint: disable-next=protected-access
256266
while transport._sock is not None:

0 commit comments

Comments
 (0)