o
    tBh                     @   s   d dl mZmZmZmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZmZmZmZmZmZmZ dgZG dd dZdS )	    )CancelledErrorEventTaskensure_futurewait)FIRST_COMPLETED)
isasyncgenisawaitable)TracebackType)AnyAsyncIterableCallableOptionalSetTypeUnionMapAsyncIteratorc                	   @   s   e Zd ZdZdededdfddZddd	Zdefd
dZ			dde
eee f dee dee ddfddZdddZedefddZejdeddfddZdS )r   a+  Map an AsyncIterable over a callback function.

    Given an AsyncIterable and a callback function, return an AsyncIterator which
    produces values mapped via calling the callback function.

    When the resulting AsyncIterator is closed, the underlying AsyncIterable will also
    be closed.
    iterablecallbackreturnNc                 C   s   |  | _|| _t | _d S )N)	__aiter__iteratorr   r   _close_event)selfr   r    r   {/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/graphql/execution/map_async_iterator.py__init__   s   
zMapAsyncIterator.__init__c                 C   s   | S )zGet the iterator object.r   r   r   r   r   r      s   zMapAsyncIterator.__aiter__c                    s   | j rt| jst| j I dH }nPt| j }t| j }zt||gtdI dH d }W n t	yH   |
  |
  |  I dH   w |D ]}|
  qK| rXt| }|r`|| }| |}t|rr|I dH S |S )z#Get the next value of the iterator.N)return_when   )	is_closedr   r   StopAsyncIteration	__anext__r   r   r   r   r   cancelaclosedone	exceptionresultr   r	   )r   valuer$   anextpendingtaskerrorr'   r   r   r   r"      s6   


zMapAsyncIterator.__anext__type_r(   	tracebackc                    s   | j rdS t|tr|}t|}|j}t| jdd}|r,||du r$|n|I dH  dS |  I dH  |du rG|du r=|t|trD|n| }|durP||}|)z2Throw an exception into the asynchronous iterator.Nathrow)	r    
isinstanceBaseExceptiontype__traceback__getattrr   r$   with_traceback)r   r-   r(   r.   r/   r   r   r   r/   C   s$   

zMapAsyncIterator.athrowc                    sL   | j s$t| jdd}|rz| I dH  W n	 ty   Y nw d| _ dS dS )zClose the iterator.r$   NT)r    r4   r   RuntimeError)r   r$   r   r   r   r$   ]   s   
zMapAsyncIterator.aclosec                 C   s
   | j  S )z%Check whether the iterator is closed.)r   is_setr   r   r   r   r    h   s   
zMapAsyncIterator.is_closedc                 C   s    |r	| j   dS | j   dS )zMark the iterator as closed.N)r   setclear)r   r(   r   r   r   r    m   s   )r   r   )NN)r   N)__name__
__module____qualname____doc__r   r   r   r   r   r"   r   r1   r   r   r
   r/   r$   propertyboolr    setterr   r   r   r   r      s*    	
(

N)asyncior   r   r   r   r   concurrent.futuresr   inspectr   r	   typesr
   typingr   r   r   r   r   r   r   __all__r   r   r   r   r   <module>   s    $