o
    i                     @  sN   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 dZ
dS )	zBPair of ZMQ inproc sockets used for communication between threads.    )annotations)AnyN)IOLoop)	ZMQStreamc                   @  sV   e Zd ZU dZded< ded< dZded< dddZdd ZddddZdddZ	dS )
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_streamcontextzmq.Context[Any]namestrc                 C  sB   | tj| _| tj| _| |}| j| | j| dS )z"Initialize the inproc socker pair.N)socketzmqPAIRr   r   _addressbindconnect)selfr
   r   address r   P/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/ipykernel/socket_pair.py__init__   s
   
zSocketPair.__init__c                 C  s,   | j   | jdur| j  | j  dS )zClose the inproc socker pair.N)r   closer	   r   )r   r   r   r   r   !   s   


zSocketPair.closeFio_loopr   copyboolc                 C  s,   | j du rt| j|| _ | j j||d dS )zBSet the callback used when a message is received on the to stream.N)r   )r	   r   r   on_recv)r   r   on_recv_callbackr   r   r   r   r   )   s   
zSocketPair.on_recvreturnc                 C  s
   d| S )z4Return the address used for this inproc socket pair.zinproc://subshellr   )r   r   r   r   r   r   0   s   
zSocketPair._address)r
   r   r   r   )F)r   r   r   r   )r   r   )
__name__
__module____qualname____doc____annotations__r	   r   r   r   r   r   r   r   r   r      s   
 
r   )r#   
__future__r   typingr   r   tornado.ioloopr   zmq.eventloop.zmqstreamr   r   r   r   r   r   <module>   s    