Current File : //usr/local/apps/python3/lib/python3.11/site-packages/asgiref/__pycache__/testing.cpython-311.pyc |
�
�rRh�
� �P � d dl Z d dlZd dlZddlmZ ddlmZ G d� d� � ZdS )� N� )�guarantee_single_callable)�timeoutc �D � e Zd ZdZd� Zdd�Zdd�Zd� Zd� Zdd �Z dd�Z
d
S )�ApplicationCommunicatorz}
Runs an ASGI application in a test mode, allowing sending of
messages to it and retrieval of messages it sends.
c �Z � t |� � | _ || _ t j � � | _ t j � � | _ t j � � � t j
| � || j j | j j � � � � | _
d S �N)r �application�scope�asyncio�Queue�input_queue�output_queue�contextvars�Context�run�create_task�get�put�future)�selfr
r s �G/usr/local/apps/python3/lib/python3.11/site-packages/asgiref/testing.py�__init__z ApplicationCommunicator.__init__ s� � �4�[�A�A�����
�"�=�?�?���#�M�O�O���
"�)�+�+�/�/������U�D�$4�$8�$�:K�:O�P�P�
�
����� r c � �^ K � t |� � 4 �d{V �� | j � d{V �� | j � � � n# t j $ r Y nw xY wddd� � �d{V �� n# 1 �d{V ��swxY w Y | j � � � s?| j � � � | j � d{V �� dS # t j $ r Y dS w xY wdS # | j � � � s=| j � � � | j � d{V �� w # t j $ r Y w w xY ww xY w)zV
Waits for the application to stop itself and returns any exceptions.
N)�
async_timeoutr �resultr �CancelledError�done�cancel)r r s r �waitzApplicationCommunicator.wait s � � � �
�$�W�-�-�
�
�
�
�
�
�
�
���+�%�%�%�%�%�%�%��K�&�&�(�(�(�(���-� � � ��D�����
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
� �;�#�#�%�%�
���"�"�$�$�$���+�%�%�%�%�%�%�%�%�%���-� � � ��D�D�����
�
��4�;�#�#�%�%�
���"�"�$�$�$���+�%�%�%�%�%�%�%�%���-� � � ��D�����
���s� �C �A)�&A�A)�A�A)�A�A)�C �)
A3�3C �6A3�7C �-
B<