
    <|h                     @   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddgZ e	d	      j                   e       d
<   ej                   e       d<   ej                   e       d<    G d de      Zd Z G d de
      Z G d de      ZddlmZ  e e       d       y)z5
Iterators across greenlets or AsyncResult objects.

    )absolute_import)division)print_function)lock)queueIMapUnorderedIMapgeventGreenlet	SemaphoreUnboundQueuec                       e Zd ZdZddZy)Failureexcraise_exceptionNc                      || _         || _        y Nr   )selfr   r   s      K/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/_imap.py__init__zFailure.__init__   s    .    r   )__name__
__module____qualname__	__slots__r    r   r   r   r      s    *I/r   r   c                 T    | j                   r| j                          y | j                  r   )r   r   )failures    r   
_raise_excr    $   s!    !kkr   c                   ^    e Zd ZdZddZd Zd ZeZd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zy)r   z%
    At iterator of map results.
    Nc                     t         j                  |        || _        || _        || _        || _        t               | _        |rt        |      | _	        nd| _	        d| _
        d| _        d| _        y)a  
        An iterator that.

        :param callable spawn: The function we use to create new greenlets.
        :keyword int maxsize: If given and not-None, specifies the maximum number of
            finished results that will be allowed to accumulated awaiting the reader;
            more than that number of results will cause map function greenlets to begin
            to block. This is most useful is there is a great disparity in the speed of
            the mapping code and the consumer and the results consume a great deal of resources.
            Using a bound is more computationally expensive than not using a bound.

        .. versionchanged:: 1.1b3
            Added the *maxsize* parameter.
        Nr   F)r   r   spawn_zippedfunciterabler   r   r   _result_semaphore_outstanding_tasks
_max_indexfinished)r   r&   r'   r$   maxsizer%   s         r   r   zIMapUnordered.__init__0   sk     	$
	 !^
   &/w%7D"%)D""# r   c                     | S r   r   r   s    r   __iter__zIMapUnordered.__iter__c   s    r   c                     | j                   | j                   j                          | j                         }t        |t              rt        |       |S r   )r(   release_inext
isinstancer   r    )r   values     r   __next__zIMapUnordered.__next__f   sB    !!-""**,eW%ur   c                 6    | j                   j                         S r   )r   getr.   s    r   r2   zIMapUnordered._inextp   s    zz~~r   c                 "   | j                   | j                   j                          | xj                  dz  c_        | j                  s| j	                  ||      n | j                  |g| }||_        |j                  | j                         |S N   )r(   acquirer)   r%   r$   _imap_task_indexrawlink
_on_result)r   r&   item
item_indexgs        r   _ispawnzIMapUnordered._ispawns   sv    !!-""**,1$*.,,DJJtT"JDJJt<Sd<S'			$//"r   c                    	 | j                   }| j                  D ]4  }| xj                  dz  c_        | j                  ||| j                         6 | j	                  d        	 d | _        d | _         d | _        d | _        y # t
        $ r}| j	                  |        d }~ww xY w# d | _        d | _         d | _        d | _        w xY wr9   )r&   r'   r*   rB   
_on_finishBaseExceptionr$   r(   )r   r&   r?   es       r   _runzIMapUnordered._run|   s    	*99D :1$T49: OOD!
 DJDI DM%)D"  	OOA	 DJDI DM%)D"s$   A B   	B 	BB  B# #Cc                    | xj                   dz  c_         | j                   }| j                  }| j                         }d}|r|dk  r|sdx}| _        d}|j                         r+| j                  j                  | j                  |             n*| j                  j                  | j                  |             |r*| j                  j                  | j                                y y )Nr:   Fr   T)	r)   r+   ready
successfulr   put_iqueue_value_for_success_iqueue_value_for_failure_iqueue_value_for_self_finished)r   greenletcountr+   rI   put_finisheds         r   r>   zIMapUnordered._on_result   s    1$''==

UaZ'++Ht}L JJNN499(CDJJNN499(CDJJNN4??AB r   c                    | j                   ry |2d| _         | j                  j                  | j                  |             y | j                  dk  r1d| _         | j                  j                  | j                                y y )NTr   )r+   r   rK   _iqueue_value_for_self_failurer)   rN   r   	exceptions     r   rD   zIMapUnordered._on_finish   sj    ==  DMJJNN4>>yIJ""a' DMJJNN4??AB (r   c                     |j                   S r   )r4   r   rO   s     r   rL   z'IMapUnordered._iqueue_value_for_success   s    ~~r   c                 B    t        |j                  t        |d            S )N_raise_exception)r   rU   getattrrW   s     r   rM   z'IMapUnordered._iqueue_value_for_failure   s    x))78=O+PQQr   c                 (    t        t                     S r   )r   StopIterationr.   s    r   rN   z-IMapUnordered._iqueue_value_for_self_finished   s    }''r   c                 .    t        || j                        S r   )r   rY   rT   s     r   rS   z,IMapUnordered._iqueue_value_for_self_failure   s    y$"7"788r   )NF)r   r   r   __doc__r   r/   r5   nextr2   rB   rG   r>   rD   rL   rM   rN   rS   r   r   r   r   r   +   sN    /f D * C(CR(9r   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)r	   c                 R    i | _         d| _        t        j                  | g|i | y )Nr   )_resultsindexr   r   )r   argskwargss      r   r   zIMap.__init__   s*     
t5d5f5r   c                    	 | j                   j                  | j                        }| xj                  dz  c_        |S # t        $ rA 	 | j                  j                         \  }}|| j                  k(  rn|| j                   |<   =Y `w xY wr9   )rb   poprc   KeyErrorr   r7   )r   r4   rc   s      r   r2   zIMap._inext   s    	-MM%%djj1E 	

a
  	-#zz~~/uDJJ&',e$	  	-s   %> ABBc                 F    |j                   t        j                  | |      fS r   )r<   r   rL   rW   s     r   rL   zIMap._iqueue_value_for_success   "    ))=+R+RSWYa+bccr   c                 F    |j                   t        j                  | |      fS r   )r<   r   rM   rW   s     r   rM   zIMap._iqueue_value_for_failure   rj   r   c                 J    | j                   dz   t        j                  |       fS r9   )r*   r   rN   r.   s    r   rN   z$IMap._iqueue_value_for_self_finished   s"    !#]%R%RSW%XYYr   c                 L    | j                   dz   t        j                  | |      fS r9   )r*   r   rS   rT   s     r   rS   z#IMap._iqueue_value_for_self_failure   s%    !#]%Q%QRVXa%bccr   N)	r   r   r   r   r2   rL   rM   rN   rS   r   r   r   r	   r	      s$    
6ddZdr   )import_c_accelzgevent.__imapN)r^   
__future__r   r   r   r
   r   r   __all__
__import__r   localsr   r   objectr   r    r   r	   gevent._utilrn   globalsr   r   r   <module>rv      s   
 '  %   

 "(+44   -- /f /M9H M9`$d= $dL ( wy/ *r   