
    oi                    n    d Z ddlmZ ddlZddlmZ ddlmZ ddlZddl	m
Z
 ddlmZmZ  G d	 d
e      Zy)zA thread for a shell channel.    )annotationsN)current_thread)Any   )SubshellManager)SHELL_CHANNEL_THREAD_NAME
BaseThreadc                  J     e Zd ZdZ	 	 	 	 d fdZedd       Zd fdZ xZS )ShellChannelThreadzqA thread for a shell channel.

    Communicates with shell/subshell threads via pairs of ZMQ inproc sockets.
    c                    t        |   ddt        i| d| _        || _        || _        t               | _        t        j                         | _
        y)zInitialize the thread.nameN )super__init__r   _manager_zmq_context_shell_socketr   parent_threadasyncioLockasyncio_lock)selfcontextshell_socketkwargs	__class__s       ^/home/ubuntu/docker-apps/notebooks/venv/lib/python3.12/site-packages/ipykernel/shellchannel.pyr   zShellChannelThread.__init__   sK     	B7B6B04#)+-#LLN    c                    | j                   It               | j                  k(  sJ t        | j                  | j
                  | j                        | _         | j                   S )N)r   r   r   r   r   io_loopr   )r   s    r   managerzShellChannelThread.manager%   sV     == !#t'9'9999+!!""DM
 }}r   c                    	 t         |           | j                  r| j                  j                          yy# | j                  r| j                  j                          w w xY w)zRun the thread.N)r   runr   close)r   r   s    r   r#   zShellChannelThread.run1   sJ    	&GKM}}##% t}}##% s	   9 )A")r   zzmq.Context[Any]r   zzmq.Socket[Any])returnr   )r%   None)	__name__
__module____qualname____doc__r   propertyr!   r#   __classcell__)r   s   @r   r   r      s=    
+!+ &+  	 	& &r   r   )r*   
__future__r   r   	threadingr   typingr   zmqsubshell_managerr   threadr   r	   r   r   r   r   <module>r3      s)    # "  $  
 - 9(& (&r   