Skip to content

fix: remove the use of asyncio.get_child_watcher() for python3.14 #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions pynvim/msgpack_rpc/event_loop/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,20 @@ 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 +260,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
Loading