Skip to content
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

Use threading.Event for _eventloop_set instead of anyio.Event #1293

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import zmq
import zmq.asyncio
from anyio import create_task_group, run
from anyio import create_task_group, run, to_thread
from IPython.core.application import ( # type:ignore[attr-defined]
BaseIPythonApplication,
base_aliases,
Expand Down Expand Up @@ -738,7 +738,7 @@ def start(self) -> None:
return

async def _wait_to_enter_eventloop(self):
await self.kernel._eventloop_set.wait()
await to_thread.run_sync(self.kernel._eventloop_set.wait)
await self.kernel.enter_eventloop()

async def main(self):
Expand Down
9 changes: 4 additions & 5 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import psutil
import zmq
from anyio import TASK_STATUS_IGNORED, Event, create_task_group, sleep, to_thread
from anyio import TASK_STATUS_IGNORED, create_task_group, sleep, to_thread
from anyio.abc import TaskStatus
from IPython.core.error import StdinNotImplementedError
from jupyter_client.session import Session
Expand Down Expand Up @@ -226,7 +226,7 @@ def _parent_header(self):
"list_subshell_request",
]

_eventloop_set: Event = Event()
_eventloop_set: threading.Event = threading.Event()

def __init__(self, **kwargs):
"""Initialize the kernel."""
Expand Down Expand Up @@ -553,9 +553,8 @@ async def start(self, *, task_status: TaskStatus = TASK_STATUS_IGNORED) -> None:
tg.start_soon(self.shell_main, None)

def stop(self):
if not self._eventloop_set.is_set():
# Stop the async task that is waiting for the eventloop to be set.
self._eventloop_set.set()
# Stop the async task that is waiting for the eventloop to be set.
self._eventloop_set.set()

self.shell_stop.set()
self.control_stop.set()
Expand Down
Loading