Skip to content

Commit 668956b

Browse files
committed
Avoid circular imports
1 parent 804708a commit 668956b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

ipykernel/shellchannel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def manager(self) -> SubshellManager:
3333
if self._manager is None:
3434
self._manager = SubshellManager(
3535
self._context,
36-
self,
36+
self.io_loop,
3737
self._shell_socket,
3838
)
3939
return self._manager

ipykernel/subshell_manager.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
from threading import Lock, current_thread, main_thread
99

1010
import zmq
11+
from tornado.ioloop import IOLoop
1112
from zmq.eventloop.zmqstream import ZMQStream
1213

1314
from .subshell import SubshellThread
1415
from .thread import SHELL_CHANNEL_THREAD_NAME
1516
from .utils import create_inproc_pair_socket
1617

17-
if t.TYPE_CHECKING:
18-
from .shellchannel import ShellChannelThread
19-
2018

2119
class SubshellManager:
2220
"""A manager of subshells.
@@ -36,13 +34,13 @@ class SubshellManager:
3634
def __init__(
3735
self,
3836
context: zmq.Context[t.Any],
39-
shell_channel_thread: ShellChannelThread,
37+
shell_channel_io_loop: IOLoop,
4038
shell_socket: zmq.Socket[t.Any],
4139
):
4240
assert current_thread() == main_thread()
4341

4442
self._context: zmq.Context[t.Any] = context
45-
self._shell_channel_thread = shell_channel_thread
43+
self._shell_channel_io_loop = shell_channel_io_loop
4644
self._shell_socket = shell_socket
4745
self._cache: dict[str, SubshellThread] = {}
4846
self._lock_cache = Lock()
@@ -53,15 +51,15 @@ def __init__(
5351
# thread, and an "other" socket used in the other thread.
5452
control_shell_channel_socket = create_inproc_pair_socket(self._context, "control", True)
5553
self._control_shell_channel_stream = ZMQStream(
56-
control_shell_channel_socket, self._shell_channel_thread.io_loop
54+
control_shell_channel_socket, self._shell_channel_io_loop
5755
)
5856
self._control_shell_channel_stream.on_recv(self._process_control_request, copy=True)
5957

6058
self._control_other_socket = create_inproc_pair_socket(self._context, "control", False)
6159

6260
parent_shell_channel_socket = create_inproc_pair_socket(self._context, None, True)
6361
self._parent_shell_channel_stream = ZMQStream(
64-
parent_shell_channel_socket, self._shell_channel_thread.io_loop
62+
parent_shell_channel_socket, self._shell_channel_io_loop
6563
)
6664
self._parent_shell_channel_stream.on_recv(self._send_on_shell_channel, copy=False)
6765

0 commit comments

Comments
 (0)