a
    xd                     @   sH   d dl Z d dlmZ ddlmZ G dd dZG dd dZd	d
 ZdS )    N)wraps   )isasyncgenfunctionc                   @   s$   e Zd Zdd Zdd Zdd ZdS )aclosingc                 C   s
   || _ d S N_aiter)selfZaiter r
   M/var/www/html/Ranjet/env/lib/python3.9/site-packages/async_generator/_util.py__init__   s    zaclosing.__init__c                    s   | j S r   r   r	   r
   r
   r   
__aenter__
   s    zaclosing.__aenter__c                    s   | j  I d H  d S r   )r   aclose)r	   argsr
   r
   r   	__aexit__   s    zaclosing.__aexit__N)__name__
__module____qualname__r   r   r   r
   r
   r
   r   r      s   r   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )_AsyncGeneratorContextManagerc                 C   s    |j | _||i | | _d S r   )r   
_func_name	__aiter___agen)r	   funcr   kwdsr
   r
   r   r      s    z&_AsyncGeneratorContextManager.__init__c                    sN   t jdk r| jI d H | _z| jd I d H W S  tyH   tdd Y n0 d S )N)         zasync generator didn't yield)sysversion_infor   asendStopAsyncIterationRuntimeErrorr   r
   r
   r   r      s    
z(_AsyncGeneratorContextManager.__aenter__c                    s  t | j4 I d H  |d u rhz| jd I d H  W n& tyZ   Y W d   I d H  dS 0 tdn4|d ustJ z$| j|||I d H  tdW n ty } z(||uW  Y d }~W  d   I d H  S d }~0  tyd } zt||u rW Y d }~W d   I d H  dS t|ttfrN|j|u rNW Y d }~W d   I d H  dS  W Y d }~n@d }~0    t	
 d |u rY W d   I d H  dS  Y n0 W d   I d H  q1 I d H s0    Y  d S )NFzasync generator didn't stopz*async generator didn't stop after athrow()r   )r   r   r    r!   r"   athrow
isinstanceStopIteration	__cause__r   exc_info)r	   typevalue	tracebackexcr
   r
   r   r   &   s6    
0
  z'_AsyncGeneratorContextManager.__aexit__c                 C   s   t dj| jdd S )Nz>use 'async with {func_name}(...)', not 'with {func_name}(...)')	func_name)r"   formatr   r   r
   r
   r   	__enter__V   s
    z'_AsyncGeneratorContextManager.__enter__c                 C   s   dsJ dd S )NFz#Never called, but should be definedr
   r   r
   r
   r   __exit__\   s    z&_AsyncGeneratorContextManager.__exit__N)r   r   r   r   r   r   r.   r/   r
   r
   r
   r   r      s
   0r   c                    s.   t  stdt  fdd}d|_|S )z Like @contextmanager, but async.z{must be an async generator (native or from async_generator; if using @async_generator then @acontextmanager must be on top.c                     s   t  | |S r   )r   )r   r   r   r
   r   helperh   s    z#asynccontextmanager.<locals>.helperT)r   	TypeErrorr   Z__returns_acontextmanager__)r   r1   r
   r0   r   asynccontextmanager`   s    r3   )r   	functoolsr   _implr   r   r   r3   r
   r
   r
   r   <module>   s
   G