
    <|hG                     B   d dl m Z  d dlZd dlZd dlmZ d dlmZ d dlmZ	 d dl
Zd dlZd dlmZ d dlZ G d dej                        Zd Z G d	 d
e      Z G d de	j                        Z G d de      Zd3dZd Zd Zd Zd\  ZZZdZdZe	j<                  re	j>                  se	j@                  se	jB                  rdZne	jD                  se	jF                  rdZ G d de	j                        Z$e	jJ                   G d de$             Z&e	jJ                   G d de$             Z'e	jJ                   G d de$             Z( G d  d!e$      Z) G d" d#e	j                        Z* G d$ d%ej                  jV                  jX                        Z- G d& d'ej                  jV                  jX                        Z. G d( d)e	j                        Z/ G d* d+e	j                        Z0d, Z1 G d- d.e	j                        Z2d/ Z3 G d0 d1e	j                        Z4e5d2k(  r e	jl                          yy)4    )timeN)Event)QueueExpectedExceptionc                       e Zd Zej                  j
                  Zd Zd Zd Z	de	_
        d Zd Zd Z ej                  d      d	        Zy
)TestCoroutinePoolc                     t               fd}| j                  d      }|j                  |d       j                          y )Nc                 &    j                          y N)set)_dones    V/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/tests/test__pool.py	some_workz5TestCoroutinePool.test_apply_async.<locals>.some_work   s    HHJ       x)r   klassapply_asyncwait)selfr   poolr   s      @r   test_apply_asyncz"TestCoroutinePool.test_apply_async   s7    w	 zz!}G,		r   c                 |    dfd}| j                  d      }|j                  |      }| j                  |       y )Nzreturn valuec                       S r    )values   r   r   z/TestCoroutinePool.test_apply.<locals>.some_work   s    Lr   r   r   applyassertEqual)r   r   r   resultr   s       @r   
test_applyzTestCoroutinePool.test_apply   s:    	 zz!}I&'r   c                     | j                  d      }d }	 |j                  |       | j                  d       y # t        $ r Y y w xY w)N   c                      t               r   r   r   r   r   raiserz3TestCoroutinePool.test_apply_raises.<locals>.raiser)   s    #%%r   z$Should have raised ExpectedException)r   r!   failr   )r   r   r(   s      r   test_apply_raisesz#TestCoroutinePool.test_apply_raises&   sH    zz!}	&	>JJv II<= ! 		s   9 	AAFc                     t               g fd}fd}| j                  d      }|j                  |      }|j                  |       |j	                          | j                  g d       y )Nc                  r    t        j                  d       j                  d        j                          y )NMbP?prod)geventsleepappendr   evtresultss   r   producerz7TestCoroutinePool.test_multiple_coros.<locals>.producer:   s$    LLNN6"GGIr   c                  j    j                  d        j                          j                  d       y )Ncons1cons2)r1   r   r2   s   r   consumerz7TestCoroutinePool.test_multiple_coros.<locals>.consumer?   s$    NN7#HHJNN7#r   r   )r7   r.   r8   )r   r   spawnr   getr"   )r   r5   r9   r   r   r3   r4   s        @@r   test_multiple_corosz%TestCoroutinePool.test_multiple_coros6   s^    g	
	$
 zz!}zz(#"
3W=r   c                     g fdfd}| j                  d      }|j                  |       t        j                  d       | j	                  g        y )Nc                  (     j                  d       y )NT)r1   )timer_fireds   r   
fire_timerz<TestCoroutinePool.dont_test_timer_cancel.<locals>.fire_timerM   s    t$r   c                  2    t        j                  d        y )Nr   )r/   timer)r@   s   r   r   z;TestCoroutinePool.dont_test_timer_cancel.<locals>.some_workP   s    LLJ'r   r   r   )r   r!   r/   r0   r"   )r   r   r   r@   r?   s      @@r   dont_test_timer_cancelz(TestCoroutinePool.dont_test_timer_cancelJ   sH    	%	( zz!}

9Qb)r   c                     | j                  d      }|j                  |j                  d df      }| j                  |d       t               }|j	                  |j
                         |j                          y )Nr&   c                     | dz   S )Nr&   r   as    r   <lambda>z2TestCoroutinePool.test_reentrant.<locals>.<lambda>Z   s
    1q5 r         )r   r!   r"   r   r   r   r   )r   r   r#   r3   s       r   test_reentrantz TestCoroutinePool.test_reentrantX   sZ    zz!}DJJ%(@A#g!
r   zDoes not work on PyPyc                    dd l }| j                  d      }|j                  }	 t               |_        |j	                  t
              }t        j                  d      5  | j                  t        |j                         d d d        t        j                  d       | j                  |j                         d       t        j                  j                  d      5  |j                  t        j                  d       d d d        ||_        |j!                          y # 1 sw Y   xY w# 1 sw Y   -xY w# ||_        |j!                          w xY w)Nr   r&   sizer   皙?)r   )sysr   stderrFakeFiler:   crashr/   TimeoutassertRaisesRuntimeErrorr;   r0   r"   
free_count	start_newr!   join)r   rQ   r   
normal_errwaiters        r   test_stderr_raisingz%TestCoroutinePool.test_stderr_raising`   s    
 	zzqz! ZZ
	!CJZZ&F" < !!,

;< LLOT__.2))#. 0

6<</0 $CJIIK)< < 0 0 $CJIIKs<   9D3 !D>AD3 !D';D3 D$ D3 'D0,D3 3EN)__name__
__module____qualname__r/   r   Poolr   r   r$   r*   error_fatalr<   rC   rL   	greentest
skipOnPyPyr]   r   r   r   r	   r	      s\    KKE(
> %*!>(* Y12! 3!r   r	   c                      t        d      )Nz*Raising an error from the crash() functionrW   )_args_kws     r   rT   rT      s    
C
DDr   c                       e Zd Zd Zy)rS   c                     t        d      )NzWriting to the file failedrf   )r   rg   s     r   writezFakeFile.write   s    788r   N)r^   r_   r`   rk   r   r   r   rS   rS      s    9r   rS   c                       e Zd Zej                  j
                  Zd Zd Zd Z	e
j                  d        Ze
j                  d        Ze
j                  d        Zd Zd Zy	)
PoolBasicTestsc                    | j                  d      }| j                  |j                         d       g }|j                  |j                  d      }| j                  |j                         d       |j                          | j                  |dg       t        j                  d       | j                  |j                         d       |j                  |j                  d       | j                  d|j                                | j                  |dg       |j                  |j                  d       | j                  d|j                                | j                  |dg       |j                  |j                  d       | j                  |dg       t        j                  d       | j                  t        |      g d	       y )
Nr   rN   r&   r   )r   )   )   {Gz?)r&   r   ro   rp   )
r   r"   rX   r:   r1   r;   r/   r0   r   sorted)r   prfirsts       r   test_execute_asyncz!PoolBasicTests.test_execute_async   sM   JJAJ+!$+		QC Q+ 	
ahh&ALLN+QC 	ahh&ALLN+QC 	ahh&QC TL1r   c                 N   | j                  d      }|j                  t        j                  d      }|j	                  |       |j                          | j                  |       | j                  t        |      d       | j                  |j                  j                  d       y )Nr&   rN     r   )r   r:   r/   r0   discardkillassertFalser"   len
_semaphorecounter)r   rs   ru   s      r   test_discardzPoolBasicTests.test_discard   sw    JJAJd+			%

Q#--q1r   c                    | j                  d      }t        j                  t        j                  d      }	 t        j                  t        j                  d      }	 | j	                  |j                         d       | j	                  t        |      d       |j                  |       | j	                  |j                         d       | j	                  t        |      d       | j                  t        j                        5  t        j                  d      5  |j                  |       d d d        d d d        | j	                  |j                         d       | j	                  t        |      d       |j                          	 |j                          y # 1 sw Y   nxY w# 1 sw Y   rxY w# |j                          w xY w# |j                          w xY w)Nr&   rN   rx   r   rP   )r   r/   r:   r0   r"   rX   r|   addrV   rU   rz   r   rs   ru   seconds       r   test_add_methodzPoolBasicTests.test_add_method   sJ   JJAJV\\40	\\&,,5F  3  Q+e  3  Q+&&v~~6 &, &f&&   3  Q+JJL& && & JJLsU   $G B&F0 F$F+F$3AF0 6G F!	F$$F-)F0 0GG Gc                    | j                  d      }t        j                  t        j                  d      }	 t        j                  t        j                  d      }	 |j	                  |       | j                  t        j                  j                        5  |j	                  |d       d d d        |j                          	 |j                          y # 1 sw Y   +xY w# |j                          w xY w# |j                          w xY w)Nr&   rN   rx   F)blocking	r   r/   r:   r0   r   rV   r   PoolFullrz   r   s       r   test_add_method_non_blockingz+PoolBasicTests.test_add_method_non_blocking   s    JJAJV\\40		\\&,,5Fe&&v{{';';< 2EE&5E12 JJL2 2 JJL;   $C6 :C! C+C! 3C6 CC! !C33C6 6Dc                    | j                  d      }t        j                  t        j                  d      }	 t        j                  t        j                  d      }	 |j	                  |       | j                  t        j                  j                        5  |j	                  |d       d d d        |j                          	 |j                          y # 1 sw Y   +xY w# |j                          w xY w# |j                          w xY wNr&   rN   rx   rP   timeoutr   r   s       r   test_add_method_timeoutz&PoolBasicTests.test_add_method_timeout   s    JJAJV\\40		\\&,,5Fe&&v{{';';< 1EE&%E01 JJL1 1 JJLr   c                    | j                  d      }t        j                  t        j                  d      }	 t        j                  t        j                  d      }	 |j                  |       | j                  t        j                  j                        5  |j                  |d       d d d        |j                          	 |j                          y # 1 sw Y   +xY w# |j                          w xY w# |j                          w xY wr   )r   r/   r:   r0   Greenletr   rV   r   r   startrz   r   s       r   test_start_method_timeoutz(PoolBasicTests.test_start_method_timeout   s    JJAJV\\40		__V\\48Fe&&v{{';';< 3GGFEG23 JJL3 3 JJLr   c                 n    | j                         }|j                  d d      }| j                  |d       y )Nc                 
    d| fS )Nfoor   rF   s    r   rH   z+PoolBasicTests.test_apply.<locals>.<lambda>   s
    E1: r   )r&   )r   r&   r    )r   rs   r#   s      r   r$   zPoolBasicTests.test_apply   s.    JJL-u5,r   c                 T    d| _         | j                  t        | j                  d       y )NF)switch_expectedrV   
ValueErrorr   r   s    r   test_init_errorzPoolBasicTests.test_init_error   s     $*djj"5r   N)r^   r_   r`   r/   r   ra   r   rv   r   r   rc   ignores_leakcheckr   r   r   r$   r   r   r   r   rm   rm      sx    KKE262.    !    !    !-
6r   rm   c                       e Zd Zd Zd Zy)TimingWrapperc                      || _         d | _        y r   )funcelapsed)r   r   s     r   __init__zTimingWrapper.__init__	  s    	r   c                     t               }	  | j                  |i |t               |z
  | _        S # t               |z
  | _        w xY wr   )r   r   r   )r   argskwdsts       r   __call__zTimingWrapper.__call__  s<    F	&499d+d+6A:DL46A:DLs	   0 AN)r^   r_   r`   r   r   r   r   r   r   r     s    &r   r   c                 6    t        j                  |       | | z  S r   )r/   r0   )r   r   s     r   sqrr     s    
LLq5Lr   c                     | | z  S r   r   r   s    r   squaredr     s    q5Lr   c                 `    t        j                  t        j                         dz         | | z  S )NrP   )r/   r0   randomr   s    r   sqr_random_sleepr     s"    
LL3&'q5Lr   c               #   `   K   t        d      E d {    t        j                  d       y 7 w)Nro   皙?)ranger/   r0   r   r   r   final_sleepr   #  s$     Qx
LL s   .,.)gˡE?gQ?gQ?
   rx      d   c                       e Zd Zej                  ZdZd Zd Zd Z	d Z
d Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestPoolr&   c                     t         j                  j                  |        t        j                  j                  | j                        | _        y r   )rc   TestCasesetUpr/   r   ra   rO   r   s    r   r   zTestPool.setUp8  s0      &KK$$TYY/	r   c                 8    | j                   j                          y r   )r   rZ   r   s    r   cleanupzTestPool.cleanup<  s    		r   c                     | j                   j                  }| j                   |t        d      d       | j                   |t        dddi      d       y )NrI   r   r   r   ro   	   )r   r!   r"   r   )r   papplys     r   r$   zTestPool.test_apply?  sC    T*B/R#q2A6r   c                 X   | j                   j                  }| j                   |t        t	        t
                    t        t        t        t	        t
                                 | j                   |t        t	        d            t        t        t        t	        d                         y )Nr   )r   mapr"   r   r   SMALL_RANGElistr   )r   pmaps     r   test_mapzTestPool.test_mapD  sh    yy}}c5#56S%P[J\=]8^_c5:.S%*5M0NOr   c                     | j                   j                  t        dt        f      }t	        |j
                        }| j                   |       d       | j                  |j                  t        d       y )N   1   r&   )	r   r   r   TIMEOUT1r   r;   r"   assertTimeoutAlmostEqualr   r   resr;   s      r   
test_asynczTestPool.test_asyncI  sR    ii##C!X8CGG$#%%ckk8Q?r   c                 V   g }| j                   j                  t        dt        f|j                        }t        |j                        }| j                   |       d       | j                  |j                  t        d       t        j                  d       | j                  |dg       y )Nr   )callbackr   r&   r   )r   r   r   r   r1   r   r;   r"   r   r   r/   r0   )r   r#   r   r;   s       r   test_async_callbackzTestPool.test_async_callbackO  s}    ii##C!X&--#PCGG$#%%ckk8Q?Q"&r   c                 B   | j                   j                  t        dt        dz   f      }t	        |j
                        }| j                  t        j                  |t               | j                  |j                  t        d       | j                   j                          y )NrK   r   r   r&   )r   r   r   TIMEOUT2r   r;   rV   r/   rU   r   r   rZ   r   s      r   test_async_timeoutzTestPool.test_async_timeoutX  sl    ii##C!X^)<=CGG$&..#x@%%ckk8Q?		r   c                     | j                   j                  t        t        t                    }| j                  t        |      t        t        t        t        t                                 y r   )r   imapr   r   r   r"   r   r   r   its     r   test_imap_list_smallzTestPool.test_imap_list_small_  s@    YY^^C{!34b4C{1C(D#EFr   c                     | j                   j                  t        t        t                    }t        t              D ]   }| j                  t        |      ||z         " | j                  t        t        |       y r   )	r   r   r   r   r   r"   nextrV   StopIterationr   r   is      r   test_imap_it_smallzTestPool.test_imap_it_smallc  Y    YY^^C{!34{# 	.AT"Xq1u-	.-r2r   c                     | j                   j                  t        t        t                    }t        t              D ]   }| j                  t        |      ||z         " | j                  t        t        |       y r   )	r   r   r   r   LARGE_RANGEr"   r   rV   r   r   s      r   test_imap_it_largezTestPool.test_imap_it_largei  r   r   c                     | j                   j                  t        t        t                    }| j                  t        |      t        t        t        t        t                                 y r   )	r   r   r   r   r   r"   r   r   r   r   s     r   test_imap_randomzTestPool.test_imap_randomo  sA    YY^^,eK.@Ab4GU;5G(H#IJr   c                    | j                   j                  t        t        t                    }| j                  t        |      t        t        t        t        t                                 | j                   j                  t        t        t                    }| j                  t        |      t        t        t        t        t                                 y r   )
r   imap_unorderedr   r   r   r"   rr   r   r   r   r   s     r   test_imap_unorderedzTestPool.test_imap_unordereds  s    YY%%c5+=>T#gu[7I*J%KLYY%%c5+=>T#gu[7I*J%KLr   c                     | j                   j                  t        t        t                    }| j                  t        |      t        t        t        t        t                                 y r   )
r   r   r   r   r   r"   rr   r   r   r   r   s     r   test_imap_unordered_randomz#TestPool.test_imap_unordered_randomz  sC    YY%%&6k8JKT#gu[7I*J%KLr   c                 z    | j                   j                  t        g       }| j                  t	        |      g        y r   )r   r   r   r"   r   r   s     r   test_empty_imap_unorderedz"TestPool.test_empty_imap_unordered~  s,    YY%%c2.b2&r   c                 z    | j                   j                  t        g       }| j                  t	        |      g        y r   )r   r   r   r"   r   r   s     r   test_empty_imapzTestPool.test_empty_imap  s*    YY^^C$b2&r   c                 d    | j                  | j                  j                  t        g       g        y r   )r"   r   r   r   r   s    r   test_empty_mapzTestPool.test_empty_map  s!    sB/4r   c                 R   | j                   j                  t        j                  dg| j                  xs ddz  z        }t        j                  d       t        | j                   j                        } |        | j                  |j                  dd       |j                          y )NrP   r   r                 ?)
r   	map_asyncr/   r0   rO   r   rz   assertTimeWithinRanger   rZ   )r   r#   rz   s      r   test_terminatezTestPool.test_terminate  ss    $$V\\C5TYY_"PQ<Q3RSSTYY^^,""4<<c:r   c                 Z    t        j                  t        |      dz         t        |      S )Ng      $@)r/   r0   floatstr)r   r   s     r   r0   zTestPool.sleep  s    U1X^$1vr   c                     t        | j                  j                  | j                  g d            }| j                  j                  dk(  rg d}ng d}| j                  ||       y )N)r   r&   r   r&   )1012)r   r   r   )r   r   r   r0   rO   r"   )r   r#   expecteds      r   test_imap_unordered_sleepz"TestPool.test_imap_unordered_sleep  sK    dii..tzz:FG99>>Q'H'H*r   c                     t               }|j                  d       t        j                  d|j                  t               t        | j                  j                  d |            }| j                  |dg       y )N{   rP   c                     | S r   r   r   s    r   rH   z,TestPool.test_imap_no_stop.<locals>.<lambda>  s    q r   )	r   putr/   spawn_laterr   r   r   r   r"   r   qr#   s      r   test_imap_no_stopzTestPool.test_imap_no_stop  sU    G	c
3}5diinn[!45#'r   c                     t               }|j                  d       t        j                  d|j                  t               t        | j                  j                  d |            }| j                  |dg       y )Ni  rP   c                     | S r   r   r  s    r   rH   z6TestPool.test_imap_unordered_no_stop.<locals>.<lambda>  s     r   )	r   r  r/   r  r   r   r   r   r"   r  s      r   test_imap_unordered_no_stopz$TestPool.test_imap_unordered_no_stop  sW    G	d3}5dii..{A>?$(r   c                     t        | j                  j                  t        t	                           }| j                  |g d       y N)r   r&   rp   )r   r   r   r   r   r"   r   r#   s     r   test_imap_final_sleepzTestPool.test_imap_final_sleep  s-    diinnS+-89+r   c                     t        | j                  j                  t        t	                           }| j                  |g d       y r  )r   r   r   r   r   r"   r  s     r   test_imap_unordered_final_sleepz(TestPool.test_imap_unordered_final_sleep  s/    dii..sKMBC+r   c                 $    t        t        d            }dgfd} fd} j                  j                   j                  j                  fD ]=  }dd<    ||||d      } ||      } |       } j                  t        |      |       ? y )Nr   r   c                 "    dxx   dz  cc<   | S )Nr   r&   r   )r   _jrunnings     r   short_running_funczFTestPool.test_imap_unordered_bounded_queue.<locals>.short_running_func  s    AJ!OJHr   c                       fd}|S )Nc                  0   g } t              D ]  \  }}j                  d   |dz   k  d          | j                  |       t        j                  d       j                  t        j                        dk  t        j                                | S )Nr   r   rq   )	enumerate
assertTruer1   r/   r0   r|   queue)r#   r   r   mappingr  r   s      r   readerzOTestPool.test_imap_unordered_bounded_queue.<locals>.make_reader.<locals>.reader  s    %g. QDAqOOGAJ!a%$7DMM!$LL&OOC$6!$;S=OP	Q
 r   r   )r  r  r  r   s   ` r   make_readerz?TestPool.test_imap_unordered_bounded_queue.<locals>.make_reader  s     Mr   r&   )maxsize)r   r   r   r   r   r"   rr   )	r   iterabler  r  methr  r  lr  s	   `       @r   !test_imap_unordered_bounded_queuez*TestPool.test_imap_unordered_bounded_queue  s    c
##		 II,,diinn< 	2DGAJ-x#$&G !)FAVAY1	2r   N)r^   r_   r`   rc   LARGE_TIMEOUT__timeout__rO   r   r   r$   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r0   r   r  r  r  r  r#  r   r   r   r   r   4  s    ))KD07
P
@'G33KMM''5+(),,
2r   r   c                       e Zd ZdZy)	TestPool2r   Nr^   r_   r`   rO   r   r   r   r'  r'        Dr   r'  c                       e Zd ZdZy)	TestPool3ro   Nr(  r   r   r   r+  r+    r)  r   r+  c                       e Zd ZdZy)
TestPool10r   Nr(  r   r   r   r-  r-    s    Dr   r-  c                       e Zd ZdZy)TestPoolUnlimitNr(  r   r   r   r/  r/    s    Dr   r/  c                       e Zd ZdZd Zy)	TestPool0r   c                    t         j                  j                  d      }| j                  d|j	                                | j                  |j                                | j                  d|j                  d             y )Nr   rN   rq   r   )r/   r   ra   r"   rX   r  fullwait_availabler   rs   s     r   test_wait_fullzTestPool0.test_wait_full  s_    KK!$ALLN+!A,,T,:;r   N)r^   r_   r`   rO   r6  r   r   r   r1  r1    s    D<r   r1  c                       e Zd Zd Zy)TestJoinSleepc                     t         j                  j                         }|j                  t         j                  d      }	 |j                  |       |j                          y # |j                          w xY w)Nr   r   r/   r   ra   r:   r0   rZ   rz   r   r   rs   gs       r   r   zTestJoinSleep.wait  sN    KKGGFLL"%	FF7F#FFHAFFHs    A# #A5Nr^   r_   r`   r   r   r   r   r8  r8        r   r8  c                       e Zd Zd Zy)TestJoinSleep_raise_errorc                     t         j                  j                         }|j                  t         j                  d      }	 |j                  |d       |j                          y # |j                          w xY w)Nr   T)r   raise_errorr:  r;  s       r   r   zTestJoinSleep_raise_error.wait   sP    KKGGFLL"%	FF7F5FFHAFFHs    A$ $A6Nr=  r   r   r   r@  r@    r>  r   r@  c                       e Zd ZdZd Zy)TestJoinEmptyFc                     t         j                  j                         }|j                         }| j	                  |d       y )Nzempty should return true)r/   r   ra   rZ   r  r   rs   r   s      r   testzTestJoinEmpty.test  s.    KKffh78r   N)r^   r_   r`   r   rG  r   r   r   rD  rD  	  s    O9r   rD  c                       e Zd ZdZd Zd Zy)	TestSpawnTc                    t         j                  j                  d      }| j                  t	        |      d       |j                  t         j                  d       | j                  t	        |      d       |j                  t         j                  d       | j                  t	        |      d       t        j                  t        j                  sdnd       | j                  t	        |      d       y )Nr&   r   rP   gRQ?r   )	r/   r   ra   r"   r|   r:   r0   rc   EXPECT_POOR_TIMER_RESOLUTIONr5  s     r   rG  zTestSpawn.test  s    KKQQ#	c"Q#	c"Q#!G!GTSQQ#r   c                    t         j                  j                  d      }| j                  t	        |      d       |j                  t         j                  d       | j                  t	        |      d       |j                  d      }| j                  |d       |j                         }| j                  |d       | j                  t	        |      d       y )Nr&   r   rP   rq   z*waiting on a full pool should return falsez waiting to finish should be true)
r/   r   ra   r"   r|   r:   r0   rZ   r{   r  rF  s      r   testSpawnAndWaitzTestSpawn.testSpawnAndWait  s    KKQQ#	c"Q#ffTlJKffh?@Q#r   N)r^   r_   r`   r   rG  rM  r   r   r   rI  rI    s    O$	$r   rI  c               #   &   K   d d t         w)Nr&   r   r   r   r   r   
error_iterrO  *  s     
G
G
s   c                       e Zd ZdZd Zd Zy)TestErrorInIteratorFc                     t         j                  j                  d      }| j                  t        |j
                  d t                      t        j                  d       y )Nro   c                      y r   r   r   s    r   rH   z*TestErrorInIterator.test.<locals>.<lambda>5      r   r-   )r/   r   ra   rV   r   r   rO  r0   r5  s     r   rG  zTestErrorInIterator.test3  s=    KKQ+QUUNJLQUr   c                     t         j                  j                  d      fd}| j                  t        |       t        j
                  d       y )Nro   c                  L    t         j                  d t                           S )Nc                      y r   r   r   s    r   rH   zGTestErrorInIterator.test_unordered.<locals>.unordered.<locals>.<lambda><  rT  r   )r   r   rO  )rs   s   r   	unorderedz5TestErrorInIterator.test_unordered.<locals>.unordered;  s    ((FGGr   r-   )r/   r   ra   rV   r   r0   )r   rX  rs   s     @r   test_unorderedz"TestErrorInIterator.test_unordered8  s<    KKQ	H 	+Y7Ur   N)r^   r_   r`   rb   rG  rY  r   r   r   rQ  rQ  0  s    K
r   rQ  c                     d| z  S )N      ?r   r   s    r   	divide_byr\  B  s    7Nr   c                   "    e Zd ZdZd Zd Zd Zy)TestErrorInHandlerFc                     t         j                  j                  d      }| j                  t        |j
                  t        g d       y )Nro   r&   r   r   )r/   r   ra   rV   ZeroDivisionErrorr   r\  r5  s     r   r   zTestErrorInHandler.test_mapI  s/    KKQ+QUUIyIr   c                 J   t         j                  j                  d      }|j                  t        g d      }| j                  t        |      d       | j                  t        t        |       | j                  t        |      d       | j                  t        t        |       y Nr&   r`  r[  r   )
r/   r   ra   r   r\  r"   r   rV   ra  r   r   rs   r   s      r   	test_imapzTestErrorInHandler.test_imapM  ss    KKQVVIy)b3'+T26b3'-r2r   c                 J   t         j                  j                  d      }|j                  t        g d      }| j                  t        |      d       | j                  t        t        |       | j                  t        |      d       | j                  t        t        |       y rc  )
r/   r   ra   r   r\  r"   r   rV   ra  r   rd  s      r   r   z&TestErrorInHandler.test_imap_unorderedU  su    KKQi3b3'+T26b3'-r2r   N)r^   r_   r`   rb   r   re  r   r   r   r   r^  r^  F  s    KJ33r   r^  __main__)r   )7r   r/   gevent.poolgevent.eventr   gevent.queuer   gevent.testingtestingrc   gevent.testing.timingr   r   unittestr   r	   rT   objectrS   rm   r   r   r   r   r   r   r   TIMEOUT3r   r   PYPYWINRUN_LEAKCHECKSRUN_COVERAGERUNNING_ON_CIrK  r   r   r'  r+  r-  r/  r1  timingAbstractGenericWaitTestCaser8  r@  rD  rI  rO  rQ  r\  r^  r^   mainr   r   r   <module>ry     s        "   , s)) slE9v 9r6Y'' r6p&F &


  2 (H NNy}})A)AYE[E[K	 F FKb2y!! b2H         h <	"" <FNN))EE  5 5 Q Q 9I&& 9$	"" $0),, $3++ 30 zINN r   