Skip to content

Commit e014d6a

Browse files
committed
-
1 parent 6642260 commit e014d6a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

ipykernel/kernelbase.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ async def shell_main(self, subshell_id: str | None):
420420
socket = None
421421

422422
async with create_task_group() as tg:
423+
if not socket.started.is_set():
424+
await tg.start(socket.start)
423425
tg.start_soon(self.process_shell, socket)
424426
if subshell_id is None:
425427
# Main subshell.
@@ -429,14 +431,13 @@ async def shell_main(self, subshell_id: str | None):
429431
async def process_shell(self, socket=None):
430432
# socket=None is valid if kernel subshells are not supported.
431433
_socket = t.cast(zmq_anyio.Socket, self.shell_socket if socket is None else socket)
432-
async with _socket:
433-
try:
434-
while True:
435-
await self.process_shell_message(socket=socket)
436-
except BaseException:
437-
if self.shell_stop.is_set():
438-
return
439-
raise
434+
try:
435+
while True:
436+
await self.process_shell_message(socket=socket)
437+
except BaseException:
438+
if self.shell_stop.is_set():
439+
return
440+
raise
440441

441442
async def process_shell_message(self, msg=None, socket=None):
442443
# If socket is None kernel subshells are not supported so use socket=shell_socket.

ipykernel/subshell_manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def close(self) -> None:
115115

116116
async def get_control_other_socket(self, thread: BaseThread) -> zmq_anyio.Socket:
117117
if not self._control_other_socket.started.is_set():
118-
thread.task_group.start_soon(self._control_other_socket.start)
119-
await self._control_other_socket.started.wait()
118+
await thread.task_group.start(self._control_other_socket.start)
120119
return self._control_other_socket
121120

122121
def get_other_socket(self, subshell_id: str | None) -> zmq_anyio.Socket:

0 commit comments

Comments
 (0)