Skip to content

Commit

Permalink
asyncio.get_child_watcher() has been removed in Python 3.14
Browse files Browse the repository at this point in the history
Fixes #583
  • Loading branch information
cryptomilk committed Jan 11, 2025
1 parent 4d3fbdc commit 20be075
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pynvim/msgpack_rpc/event_loop/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 20be075

Please sign in to comment.