HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/asgiref/__pycache__/testing.cpython-310.pyc
o

��hE�@sBddlZddlZddlZddlmZddlmZGdd�d�ZdS)�N�)�guarantee_single_callable)�timeoutc@steZdZdZdd�Zedd��Zedd��Zedd	��Zddd�Z	ddd�Z
dd�Zdd�Zddd�Z
ddd�ZdS)�ApplicationCommunicatorz}
    Runs an ASGI application in a test mode, allowing sending of
    messages to it and retrieval of messages it sends.
    cCs&d|_t|�|_||_d|_d|_dS�N)�_futurer�application�scope�_input_queue�
_output_queue)�selfrr	�r
�E/usr/local/CyberPanel/lib/python3.10/site-packages/asgiref/testing.py�__init__s


z ApplicationCommunicator.__init__cC�|jdur
t��|_|jSr)r
�asyncio�Queue�rr
r
r�input_queue�

z#ApplicationCommunicator.input_queuecCrr)rrrrr
r
r�output_queuerz$ApplicationCommunicator.output_queuecCs8|jdurt���tj|�|j|jj	|j
j��|_|jSr)r�contextvars�Context�runr�create_taskrr	r�getr�putrr
r
r�future$s
��zApplicationCommunicator.futurerc�s��zXt|�4IdH�#z
|jIdH|j��Wn
tjy"YnwWd�IdHn1IdHs3wYW|j��sX|j��z	|jIdHWdStjyWYdSwdS|j��sw|j��z|jIdHWwtjyvYwww)zV
        Waits for the application to stop itself and returns any exceptions.
        N)�
async_timeoutr�resultr�CancelledError�done�cancel)rrr
r
r�wait3s6���(��

��
��zApplicationCommunicator.waitTcCs:|j}|dur	dS|��s|��dS|r|��dSdSr)rr!r"r)r�
exceptionsrr
r
r�stopFs�zApplicationCommunicator.stopcCs(z	|jdd�WdStyYdSw)NF)r$)r%�RuntimeErrorrr
r
r�__del__Qs
�zApplicationCommunicator.__del__c�s,�|j��r|j��|j�|�IdHdS)z;
        Sends a single message to the application
        N)rr!rrr)r�messager
r
r�
send_inputYs�

z"ApplicationCommunicator.send_inputc�s��|j��r|j��z*t|�4IdH�|j��IdHWd�IdHWS1IdHs.wYWdStjyh}z&|j��rJ|j��|�|j��z	|jIdHW|�tj	ycY|�wd}~ww)zX
        Receives a single message from the application, with optional timeout.
        N)
rr!rrrrr�TimeoutErrorr"r )rr�er
r
r�receive_outputds*�

4�


�����z&ApplicationCommunicator.receive_output皙�����?�{�G�z�?c�sf�|j��r|j��t��}t��||kr.|j��sdSt�|�IdHt��||ks|j��S)zO
        Checks that there is no message to receive in the given time.
        FN)	rr!r�time�	monotonicr�emptyr�sleep)rr�interval�startr
r
r�receive_nothing{s�


�
z'ApplicationCommunicator.receive_nothingN)r)T)r-r.)�__name__�
__module__�__qualname__�__doc__r�propertyrrrr#r%r'r)r,r5r
r
r
rr	s	





r)rrr/�
compatibilityrrrrr
r
r
r�<module>s