@@ -29,6 +29,8 @@ class SubshellManager:
2929
3030 Sending reply messages via the shell_socket is wrapped by another lock to protect
3131 against multiple subshells attempting to send at the same time.
32+
33+ .. versionadded:: 7
3234 """
3335
3436 def __init__ (
@@ -37,6 +39,7 @@ def __init__(
3739 shell_channel_io_loop : IOLoop ,
3840 shell_socket : zmq .Socket [t .Any ],
3941 ):
42+ """Initialize the subshell manager."""
4043 assert current_thread () == main_thread ()
4144
4245 self ._context : zmq .Context [t .Any ] = context
@@ -80,22 +83,30 @@ def close(self) -> None:
8083 self ._shell_channel_to_main .close ()
8184
8285 def get_shell_channel_to_subshell_pair (self , subshell_id : str | None ) -> SocketPair :
86+ """Return the inproc socket pair used to send messages from the shell channel
87+ to a particular subshell or main shell."""
8388 if subshell_id is None :
8489 return self ._shell_channel_to_main
8590 with self ._lock_cache :
8691 return self ._cache [subshell_id ].shell_channel_to_subshell
8792
8893 def get_subshell_to_shell_channel_socket (self , subshell_id : str | None ) -> zmq .Socket [t .Any ]:
94+ """Return the socket used by a particular subshell or main shell to send
95+ messages to the shell channel.
96+ """
8997 if subshell_id is None :
9098 return self ._main_to_shell_channel .from_socket
9199 with self ._lock_cache :
92100 return self ._cache [subshell_id ].subshell_to_shell_channel .from_socket
93101
94102 def get_shell_channel_to_subshell_socket (self , subshell_id : str | None ) -> zmq .Socket [t .Any ]:
103+ """Return the socket used by the shell channel to send messages to a particular
104+ subshell or main shell.
105+ """
95106 return self .get_shell_channel_to_subshell_pair (subshell_id ).from_socket
96107
97108 def get_subshell_aborting (self , subshell_id : str ) -> bool :
98- """Get the aborting flag of the specified subshell."""
109+ """Get the boolean aborting flag of the specified subshell."""
99110 return self ._cache [subshell_id ].aborting
100111
101112 def list_subshell (self ) -> list [str ]:
@@ -107,6 +118,9 @@ def list_subshell(self) -> list[str]:
107118 return list (self ._cache )
108119
109120 def set_on_recv_callback (self , on_recv_callback ):
121+ """Set the callback used by the main shell and all subshells to receive
122+ messages sent from the shell channel thread.
123+ """
110124 assert current_thread () == main_thread ()
111125 self ._on_recv_callback = on_recv_callback
112126 self ._shell_channel_to_main .on_recv (IOLoop .current (), partial (self ._on_recv_callback , None ))
0 commit comments