88from threading import Lock , current_thread , main_thread
99
1010import zmq
11+ from tornado .ioloop import IOLoop
1112from zmq .eventloop .zmqstream import ZMQStream
1213
1314from .subshell import SubshellThread
1415from .thread import SHELL_CHANNEL_THREAD_NAME
1516from .utils import create_inproc_pair_socket
1617
17- if t .TYPE_CHECKING :
18- from .shellchannel import ShellChannelThread
19-
2018
2119class 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