OwlCyberSecurity - MANAGER
Edit File: testing.cpython-39.pyc
a gH�f� � @ sB d dl Z d dlZd dlZddlmZ ddlmZ G dd� d�ZdS )� N� )�guarantee_single_callable)�timeoutc @ sP e Zd ZdZdd� Zddd�Zddd �Zd d� Zdd � Zddd�Z ddd�Z dS )�ApplicationCommunicatorz} Runs an ASGI application in a test mode, allowing sending of messages to it and retrieval of messages it sends. c C sN t |�| _|| _t�� | _t�� | _t�� � tj | �|| jj| jj��| _ d S �N)r �application�scope�asyncio�Queue�input_queue�output_queue�contextvars�Context�run�create_task�get�put�future)�selfr r � r �Q/home/gouroczh/virtualenv/test/3.9/lib/python3.9/site-packages/asgiref/testing.py�__init__ s �z ApplicationCommunicator.__init__r c � s� z�t |�4 I dH �F z| jI dH | j�� W n tjyB Y n0 W d �I dH qn1 I dH sd0 Y W | j�� s�| j�� z| jI dH W q� tjy� Y q�0 n<| j�� s�| j�� z| jI dH W n tjy� Y n0 0 dS )zV Waits for the application to stop itself and returns any exceptions. N)� async_timeoutr �resultr �CancelledError�done�cancel)r r r r r �wait s&