Skip to content

Commit 4586e34

Browse files
committed
Pass subshell_id to _execute_request_handler
1 parent 2b3d6ec commit 4586e34

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ipykernel/kernelbase.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,20 +441,23 @@ async def shell_main(self, subshell_id: str | None):
441441
if not socket.started.is_set():
442442
await tg.start(socket.start)
443443
tg.start_soon(self._process_shell, socket)
444-
tg.start_soon(self._execute_request_handler, receive_stream)
444+
tg.start_soon(self._execute_request_handler, receive_stream, subshell_id)
445445
if subshell_id is None:
446446
# Main subshell.
447-
with contextlib.suppress(RuntimeError):
448-
self.set_trait("asyncio_event_loop", asyncio.get_running_loop())
449-
self._main_subshell_ready.set()
450447
await to_thread.run_sync(self.shell_stop.wait)
451448
tg.cancel_scope.cancel()
452449
self._send_exec_request.pop(socket, None)
453450
self.set_trait("asyncio_event_loop", None)
454451
await send_stream.aclose()
455452
await receive_stream.aclose()
456453

457-
async def _execute_request_handler(self, receive_stream: MemoryObjectReceiveStream):
454+
async def _execute_request_handler(
455+
self, receive_stream: MemoryObjectReceiveStream, subshell_id: str | None
456+
):
457+
if subshell_id is None:
458+
with contextlib.suppress(RuntimeError):
459+
self.set_trait("asyncio_event_loop", asyncio.get_running_loop())
460+
self._main_subshell_ready.set()
458461
async with receive_stream:
459462
async for handler, (received_time, socket, idents, msg) in receive_stream:
460463
try:

0 commit comments

Comments
 (0)