Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Dec 17, 2024
1 parent 4858e82 commit e22861a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ async def start(self, *, task_status: TaskStatus = TASK_STATUS_IGNORED) -> None:
manager = self.shell_channel_thread.manager
self.shell_channel_thread.start_soon(self.shell_channel_thread_main)
self.shell_channel_thread.start_soon(
partial(manager.listen_from_control, self.shell_main, self.shell_channel_thread)
partial(manager.listen_from_control, self.shell_main)
)
self.shell_channel_thread.start_soon(manager.listen_from_subshells)
self.shell_channel_thread.start()
Expand Down
14 changes: 6 additions & 8 deletions ipykernel/subshell_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,18 @@ def list_subshell(self) -> list[str]:
with self._lock_cache:
return list(self._cache)

async def listen_from_control(self, subshell_task: t.Any, thread: BaseThread) -> None:
async def listen_from_control(self, subshell_task: t.Any) -> None:
"""Listen for messages on the control inproc socket, handle those messages and
return replies on the same socket. Runs in the shell channel thread.
"""
assert current_thread().name == SHELL_CHANNEL_THREAD_NAME

if not self._control_shell_channel_socket.started.is_set():
thread.start_soon(self._control_shell_channel_socket.start)
await self._control_shell_channel_socket.started.wait()
socket = self._control_shell_channel_socket
while True:
request = await socket.arecv_json()
reply = await self._process_control_request(request, subshell_task)
await socket.asend_json(reply)
async with socket:
while True:
request = await socket.arecv_json()
reply = await self._process_control_request(request, subshell_task)
await socket.asend_json(reply)

async def listen_from_subshells(self) -> None:
"""Listen for reply messages on inproc sockets of all subshells and resend
Expand Down

0 comments on commit e22861a

Please sign in to comment.