Skip to content

Commit c9e9108

Browse files
committed
Set async event in async context
1 parent f13f7d7 commit c9e9108

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ipykernel/kernelapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ async def _start(self, backend: str) -> None:
761761

762762
def start(self) -> None:
763763
"""Start the application."""
764-
backend = "trio" if self.trio_loop else "asyncio"
764+
backend = "trio"# if self.trio_loop else "asyncio"
765765
run(partial(self._start, backend), backend=backend)
766766

767767
async def _wait_to_enter_eventloop(self) -> None:

ipykernel/kernelbase.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ async def shell_main(self, subshell_id: str | None):
422422
if subshell_id is None:
423423
# Main subshell.
424424
await to_thread.run_sync(self.shell_stop.wait)
425+
426+
if not self._eventloop_set.is_set():
427+
# Stop the async task that is waiting for the eventloop to be set.
428+
self._eventloop_set.set()
429+
425430
tg.cancel_scope.cancel()
426431

427432
async def process_shell(self, socket=None):
@@ -573,10 +578,6 @@ async def start(self, *, task_status: TaskStatus = TASK_STATUS_IGNORED) -> None:
573578
tg.start_soon(self.shell_main, None)
574579

575580
def stop(self):
576-
if not self._eventloop_set.is_set():
577-
# Stop the async task that is waiting for the eventloop to be set.
578-
self._eventloop_set.set()
579-
580581
self.shell_stop.set()
581582
self.control_stop.set()
582583

0 commit comments

Comments
 (0)