
    oi                    T    d 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	  G d d      Z
y)	zBPair of ZMQ inproc sockets used for communication between threads.    )annotations)AnyN)IOLoop)	ZMQStreamc                  T    e Zd ZU dZded<   ded<   dZded<   ddZd	 Zddd
ZddZ	y)
SocketPairzPair of ZMQ inproc sockets for one-direction communication between 2 threads.

    One of the threads is always the shell_channel_thread, the other may be the control
    thread, main thread or a subshell thread.

    .. versionadded:: 7
    zzmq.Socket[Any]from_socket	to_socketNzZMQStream | None	to_streamc                "   |j                  t        j                        | _        |j                  t        j                        | _        | j                  |      }| j                  j                  |       | j                  j                  |       y)z"Initialize the inproc socker pair.N)socketzmqPAIRr	   r
   _addressbindconnect)selfcontextnameaddresss       ]/home/ubuntu/docker-apps/notebooks/venv/lib/python3.12/site-packages/ipykernel/socket_pair.py__init__zSocketPair.__init__   s_    ">>#((3 1--%g&w'    c                    | j                   j                          | j                  | j                  j                          | j                  j                          y)zClose the inproc socker pair.N)r	   closer   r
   )r   s    r   r   zSocketPair.close!   s>     >>%NN  "r   c                    | j                   t        | j                  |      | _         | j                   j                  ||       y)zBSet the callback used when a message is received on the to stream.N)copy)r   r   r
   on_recv)r   io_loopon_recv_callbackr   s       r   r   zSocketPair.on_recv)   s8     >>!&t~~w?DN/d;r   c                    d| S )z4Return the address used for this inproc socket pair.zinproc://subshell )r   r   s     r   r   zSocketPair._address0   s    "4&))r   )r   zzmq.Context[Any]r   str)F)r   r   r   bool)returnr#   )
__name__
__module____qualname____doc____annotations__r   r   r   r   r   r"   r   r   r   r      s4     ! "&I&(<*r   r   )r)   
__future__r   typingr   r   tornado.ioloopr   zmq.eventloop.zmqstreamr   r   r"   r   r   <module>r/      s!    H "  
 ! -&* &*r   