Format: application/x-python-code
⬇ Download File (3.4 KB)
   1  o
   2  
   3  �hi�@stdZddlZddlmZmZddlmZddlmZddl	m
   4  Z
   5  Gdd	�d	e�ZGd
   6  d�de�ZGdd
   7  �d
   8  e
   9  �Z
  10  dS)zf Implements a fully blocking kernel client.
  11  
  12  Useful for test suites and blocking terminal interfaces.
  13  �N)�Empty�Queue)�Type�)�InProcessChannel)�InProcessKernelClientcsBeZdZdZ�fdd�Zdd�Zddd	�Zd
  14  d�Zdd
  15  �Z�Z	S)�BlockingInProcessChannelzA blocking in-process channel.cst�j|i|��t�|_dS)zInitialize the channel.N)�super�__init__r�	_in_queue)�self�args�kwds��	__class__��Rc:\Users\shubh\Videos\agent\nova\Lib\site-packages\ipykernel/inprocess/blocking.pyr
  16  sz!BlockingInProcessChannel.__init__cCs|j�|�dS)z Call the handlers for a message.N)r�put�r�msgrrr�
  17  call_handlerssz&BlockingInProcessChannel.call_handlersTNcCs|durd}|j�||�S)z-Gets a message if there is one that is ready.Ni�:	)r�get)r�block�timeoutrrr�get_msg#sz BlockingInProcessChannel.get_msgcCs4g}	z|�|jdd��Wn
  18  tyY|Swq)z*Get all messages that are currently ready.TF)r)�appendrr)rZmsgsrrr�get_msgs+s��z!BlockingInProcessChannel.get_msgscCs|j��S)z*Is there a message that has been received?)r�empty)rrrr�	msg_ready5sz"BlockingInProcessChannel.msg_ready)TN)
  19  �__name__�
  20  __module__�__qualname__�__doc__r
  21  rrrr�
  22  __classcell__rrrrrs
  23  
  24  rc@seZdZdZdd�ZdS)�BlockingInProcessStdInChannelz$A blocking in-process stdin channel.cCsZ|dd}|dkr+|jjj}|dd}t|dtjd�tj��|j�|��dSdS)	zfOverridden for the in-process channel.
  25  
  26          This methods simply calls raw_input directly.
  27          �header�msg_typeZ
  28  input_request�content�prompt�)�end�fileN)�clientZkernelZ_sys_raw_input�print�sys�
  29  __stdout__�flush�input)rrr&�
  30  _raw_inputr(rrrr=s
  31  
  32  �z+BlockingInProcessStdInChannel.call_handlersN)rr r!r"rrrrrr$:sr$c@s0eZdZdZee�Zee�Zee�Z	dd�Z
  33  dS)�BlockingInProcessKernelClientz$A blocking in-process kernel client.cCs�	|��z
  34  |jjddd�}Wn	tyYn!w|ddkr9z
  35  |jjddd�Wn	ty2Ynw|�|�nq	z|jjddd�}t|d�Wn
  36  tyUYdSwq;)z,Wait for kernel info reply on shell channel.Tr)rrr&Zkernel_info_replyg�������?N)Zkernel_infoZ
  37  shell_channelrrZ
  38  iopub_channelZ_handle_kernel_info_replyr-rrrr�wait_for_readySs0��
  39  ���z,BlockingInProcessKernelClient.wait_for_readyN)rr r!r"rrZshell_channel_classZiopub_channel_classr$Zstdin_channel_classr4rrrrr3Ksr3)r"r.�queuerrZ	traitletsrZchannelsrr,rrr$r3rrrr�<module>s#