o
     d                     @   sB   d dl mZ d dlmZ d dlmZmZmZmZ G dd dZ	dS )    )Optional)AsyncExitStack)ASGIAppReceiveScopeSendc                   @   s>   e Zd ZddededdfddZded	ed
eddfddZ	dS )AsyncExitStackMiddlewarefastapi_astackappcontext_namereturnNc                 C   s   || _ || _d S N)r
   r   )selfr
   r    r   L/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py__init__   s   
z!AsyncExitStackMiddleware.__init__scopereceivesendc                    s   t rJd }t  4 I d H -}||| j< z| |||I d H  W n ty. } z|}|d }~ww W d   I d H  n1 I d H s?w   Y  |rH|d S | |||I d H  d S r   )r   r   r
   	Exception)r   r   r   r   dependency_exceptionstacker   r   r   __call__   s$   
(z!AsyncExitStackMiddleware.__call__)r	   )
__name__
__module____qualname__r   strr   r   r   r   r   r   r   r   r   r      s    r   N)
typingr   fastapi.concurrencyr   starlette.typesr   r   r   r   r   r   r   r   r   <module>   s    