ó
ÐH/\c           @  sA  d  d l  m Z d  d l m Z m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l j	 Z
 d  d l Z d  d l m Z d  d l Z d  d l m Z d  d l m Z e j d „  ƒ Z d e
 j f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d d „ Z d „  Z d= \ Z Z Z d e f d „  ƒ  YZ d Z d Z e
 j ree
 j sne
 j sne
 j  rwd Z n  d e f d „  ƒ  YZ! d e! f d „  ƒ  YZ" e
 j# d e! f d „  ƒ  Yƒ Z$ e
 j# d e! f d  „  ƒ  Yƒ Z% d! e f d" „  ƒ  YZ& d# e f d$ „  ƒ  YZ' d% „  Z( d& e f d' „  ƒ  YZ) d( e f d) „  ƒ  YZ* d* e f d+ „  ƒ  YZ+ d, e f d- „  ƒ  YZ, d. e f d/ „  ƒ  YZ- d0 e f d1 „  ƒ  YZ. d2 „  Z/ d3 e f d4 „  ƒ  YZ0 e1 e j2 d5 ƒ r$d  d6 l3 m4 Z5 d  d7 l3 m6 Z7 d  d8 l3 m8 Z9 d  d9 l m: Z: d: e f d; „  ƒ  YZ; n  e< d< k r=e
 j= ƒ  n  d S(>   iÿÿÿÿ(   t   print_function(   t   timet   sleepN(   t
   ThreadPool(   t   ExpectedException(   t   PYPYc          c  s:   t  j ƒ  }  t  j ƒ  z	 d  VWd  |  r5 t  j ƒ  n  Xd  S(   N(   t   gct	   isenabledt   disablet   enable(   t   was_enabled(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   disabled_gc   s    
	t   TestCasec           B  s>   e  Z e j Z d Z e Z d  „  Z	 e j
 d „ Z d „  Z RS(   c         C  s   |  j  S(   N(   t   ClassUnderTest(   t   self(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   _FUT'   s    c         C  s2   |  j  ƒ  | ƒ |  _ } | r. | |  j _ n  | S(   N(   R   t   poolt   size(   R   R   t   increaseR   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   _makeOne*   s    c         C  sz   |  j  } | d  k	 rv t | d d  ƒ p3 t | d ƒ } | ƒ  ~ |  `  t j rv x! t d ƒ D] } t j ƒ  q\ Wqv n  d  S(   Nt   killt   shutdowni   (   R   t   Nonet   getattrt	   greentestt   RUN_LEAKCHECKSt   rangeR   t   collect(   R   R   R   t   _(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   cleanup1   s    	!	N(   t   __name__t
   __module__R   t   LARGE_TIMEOUTt   __timeout__R   R   R   R   R   R   R   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR   !   s   		t   PoolBasicTestsc           B  s5   e  Z d  „  Z d „  Z d „  Z e e _ d „  Z RS(   c         C  sù   |  j  d ƒ } g  } | j | j d ƒ } | j ƒ  |  j | d g ƒ t j d ƒ | j | j d ƒ |  j | d g ƒ | j | j d ƒ |  j | d g ƒ | j | j d	 ƒ |  j | d g ƒ t j d ƒ |  j t	 | ƒ d d d d g ƒ d  S(
   Ni   i   i    i   i   g{®Gáz„?(   i   (   i   (   i   (
   R   t   spawnt   appendt   gett   assertEqualt   geventR   t   apply_asynct   assertEqualFlakyRaceConditiont   sorted(   R   R   t   rt   first(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_execute_asyncE   s    
c         C  s8   |  j  d ƒ } | j d „  d ƒ } |  j | d ƒ d  S(   Ni   c         S  s
   d |  f S(   Nt   foo(    (   t   a(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   <lambda>Z   s    R.   (   i   (   R.   i   (   R   t   applyR&   (   R   R   t   result(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt
   test_applyX   s    c         C  s?   |  j  d ƒ } d „  } |  j t ƒ  | j | ƒ Wd  QXd  S(   Ni   c           S  s   t  ƒ  ‚ d  S(   N(   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   raiser`   s    (   R   t   assertRaisesR   R1   (   R   R   R4   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_apply_raises]   s    	c         C  s0   t  |  _ |  j t ƒ  |  j d ƒ Wd  QXd  S(   Niÿÿÿÿ(   t   Falset   switch_expectedR5   t
   ValueErrorR   (   R   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_init_valueerrorj   s    	(   R   R   R-   R3   R6   R7   t   error_fatalR:   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR"   C   s
   				t   TimingWrapperc           B  s   e  Z d  „  Z d „  Z RS(   c         C  s   | |  _  d  |  _ d  S(   N(   t   funcR   t   elapsed(   R   t   the_func(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   __init__u   s    	c         O  s5   t  ƒ  } z |  j | | Ž  SWd  t  ƒ  | |  _ Xd  S(   N(   R   R=   R>   (   R   t   argst   kwdst   t(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   __call__y   s    	(   R   R   R@   RD   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR<   s   s   	g        c         C  s   t  | ƒ |  |  S(   N(   R   (   t   xt   wait(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   sqr   s    
c         C  s   t  t j ƒ  d ƒ |  |  S(   Ngš™™™™™¹?(   R   t   random(   RE   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   sqr_random_sleep†   s    gË¡E¶óý´?gìQ¸…ë¡?gìQ¸…ëÁ?t   _AbstractPoolTestc           B  s/   e  Z d  Z e Z d „  Z e j d „  ƒ Z RS(   i   c         C  s$   t  j j |  ƒ |  j |  j ƒ d  S(   N(   R   R   t   setUpR   R   (   R   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyRK   “   s    c           s©   ˆ  j  j } ˆ  j r' ‡  f d †  } n  ˆ  j | t t d ƒ ƒ t t t t d ƒ ƒ ƒ ƒ ˆ  j | t t d ƒ ƒ t t t t d ƒ ƒ ƒ ƒ ˆ  j  j ƒ  ˆ  `  ~ d  S(   Nc           s   t  ˆ  j j |  | ƒ ƒ S(   N(   t   listR   t   map(   t   ft   i(   R   (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR0   ›   s    i
   id   (   R   RM   t
   MAP_IS_GENR&   RG   R   RL   R   (   R   t   pmap(    (   R   s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_map—   s    	44(	   R   R   R   R7   RP   RK   R   t   ignores_leakcheckRR   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyRJ      s   	i
   iè  i2   t   TestPoolc           B  s˜   e  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 RS(   c         C  s´   d d l  m } d d l m } |  j j | ƒ } |  j | | ƒ t | ƒ } |  j d | ƒ |  j d | ƒ |  j d | ƒ d d l	 m
 } d j | ƒ  ƒ } |  j d	 | ƒ d  S(
   Niÿÿÿÿ(   t
   getcurrent(   t   _WorkerGreenlett   ThreadPoolWorkert   thread_idents   hub=(   t   format_run_infos   
s   <ThreadPoolWorker(   t   greenletRU   t   gevent.threadpoolRV   R   R1   t   assertIsInstancet   reprt   assertInt   gevent.utilRY   t   join(   R   RU   RV   t   worker_greenletR+   RY   t   info(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_greenlet_class±   s    c         C  s[   |  j  j } |  j | t d ƒ t d ƒ ƒ |  j | t d i d d 6ƒ t d d ƒ ƒ d  S(   Ni   i   RE   (   i   (    (   R   R1   R&   RG   (   R   t   papply(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR3   Á   s    c         C  sW   |  j  j t d t f ƒ } t | j ƒ } |  j | ƒ  d ƒ |  j | j t d ƒ d  S(   Ni   i1   i   (	   R   R(   RG   t   TIMEOUT1R<   R%   R&   t   assertTimeoutAlmostEqualR>   (   R   t   resR%   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt
   test_asyncÆ   s    c         C  sŽ   g  } |  j  j t d t f d | j ƒ} t | j ƒ } |  j | ƒ  d ƒ |  j | j	 t d ƒ t
 j d ƒ | d g k sŠ t | ƒ ‚ d  S(   Ni   t   callbacki1   i   i    (   R   R(   RG   Re   R$   R<   R%   R&   Rf   R>   R'   R   t   AssertionError(   R   R2   Rg   R%   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_async_callbackÌ   s    $c         C  sn   |  j  j t d t d f ƒ } t | j ƒ } |  j t j | d t ƒ|  j	 | j
 t d ƒ |  j  j ƒ  d  S(   Ni   gš™™™™™É?t   timeouti   (   R   R(   RG   t   TIMEOUT2R<   R%   R5   R'   t   TimeoutRf   R>   R`   (   R   Rg   R%   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_async_timeoutÕ   s
    c         C  sJ   |  j  j t t t ƒ ƒ } |  j t | ƒ t t t t t ƒ ƒ ƒ ƒ d  S(   N(   R   t   imapRG   R   t   SMALL_RANGER&   RL   RM   (   R   t   it(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_list_smallÜ   s    c         C  sc   |  j  j t t t ƒ ƒ } x. t t ƒ D]  } |  j t | ƒ | | ƒ q( W|  j t t | ƒ d  S(   N(	   R   Rp   RG   R   Rq   R&   t   nextR5   t   StopIteration(   R   Rr   RO   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_it_smallà   s    c         C  sc   |  j  j t t t ƒ ƒ } x. t t ƒ D]  } |  j t | ƒ | | ƒ q( W|  j t t | ƒ d  S(   N(	   R   Rp   RG   R   t   LARGE_RANGER&   Rt   R5   Ru   (   R   Rr   RO   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_it_largeæ   s    c         C  sm   |  j  j t t t ƒ ƒ } x8 t t ƒ D]* } |  j t | ƒ | | ƒ t j ƒ  q( W|  j	 t
 t | ƒ d  S(   N(   R   Rp   RG   R   Rq   R&   Rt   R   R   R5   Ru   (   R   Rr   RO   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_gcì   s
    c         C  s¬   |  j  j t t t ƒ ƒ } g  } x1 t t ƒ D]# } | j t | ƒ ƒ t j ƒ  q. W|  j	 t
 ƒ  t | ƒ Wd  QX|  j t | ƒ g  t t ƒ D] } | | ^ q‘ ƒ d  S(   N(   R   t   imap_unorderedRG   R   Rq   R$   Rt   R   R   R5   Ru   R&   R*   (   R   Rr   R2   R   RE   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_unordered_gcó   s    c         C  sJ   |  j  j t t t ƒ ƒ } |  j t | ƒ t t t t t ƒ ƒ ƒ ƒ d  S(   N(	   R   Rp   RI   R   Rq   R&   RL   RM   RG   (   R   Rr   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_randomý   s    c         C  s   |  j  j t t t ƒ ƒ } |  j t | ƒ t t t t t ƒ ƒ ƒ ƒ |  j  j t t t ƒ ƒ } |  j t | ƒ t t t t t ƒ ƒ ƒ ƒ d  S(   N(	   R   Rz   RG   R   Rw   R&   R*   RL   RM   (   R   Rr   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_unordered  s    +c         C  sJ   |  j  j t t t ƒ ƒ } |  j t | ƒ t t t	 t t ƒ ƒ ƒ ƒ d  S(   N(
   R   Rz   RI   R   Rq   R&   R*   RL   RM   RG   (   R   Rr   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_unordered_random  s    c         C  sŒ   |  j  p d } |  j j t d g | d ƒ } t j d ƒ t |  j j ƒ } | ƒ  | j d |  j  d k  s~ t | j ƒ ‚ | j	 ƒ  d  S(   Ni
   gš™™™™™¹?i   g      à?(
   R   R   t	   map_asyncR   R'   R<   R   R>   Rj   R`   (   R   R   R2   R   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_terminate  s     )c         C  s   t  t | ƒ d ƒ t | ƒ S(   Ng      $@(   R   t   floatt   str(   R   RE   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR     s    c         C  sn   t  |  j j |  j d d d g ƒ ƒ } |  j j d k rK d d d g } n d d d g } |  j | | ƒ d  S(   Ni
   i   i   t   10t   1t   2(   RL   R   Rz   R   R   R&   (   R   R2   t   expected(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_imap_unordered_sleep  s
    '(   R   R   Rc   R3   Rh   Rk   Ro   Rs   Rv   Rx   Ry   R{   R|   R}   R~   R€   R   R‡   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyRT   ¯   s    											
						t	   TestPool2c           B  s    e  Z d  Z e j d „  ƒ Z RS(   i   c           sG   |  j  ‰ ‡  ‡ f d †  } d „  ‰  ˆ j | ƒ } |  j | d ƒ d  S(   Nc             s   ˆ j  ˆ  ƒ S(   N(   R1   (    (   t   bt   p(    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR/   *  s    c           S  s   t  j ƒ  t  j d ƒ d S(   Ngü©ñÒMbP?t   B(   R'   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR‰   -  s    
R‹   (   R   R1   R&   (   R   R/   R2   (    (   R‰   RŠ   s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_recursive_apply&  s
    		(   R   R   R   R   RS   RŒ   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyRˆ   #  s   t	   TestPool3c           B  s   e  Z d  Z RS(   i   (   R   R   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR   9  s   t
   TestPool10c           B  s   e  Z d  Z RS(   i
   (   R   R   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyRŽ   =  s   t   TestJoinEmptyc           B  s>   e  Z e Z e j e j o* e j o* e j d  ƒ d „  ƒ Z	 RS(   sq   This sometimes appears to crash in PyPy2 5.9.0, but never crashes on macOS or local Ubunto with same PyPy versionc         C  s   |  j  d ƒ } | j ƒ  d  S(   Ni   (   R   R`   (   R   R   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   testV  s    (
   R   R   R7   R8   R   t   skipIfR   t   LIBUVt   RUNNING_ON_TRAVISR   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR   S  s   t	   TestSpawnc           B  s    e  Z e Z e j d  „  ƒ Z RS(   c           sÿ   |  j  d ƒ } |  j t | ƒ d ƒ g  ‰  ‡  f d †  } | j | d d ƒ |  j t | ƒ d ƒ | j | d d ƒ |  j t | ƒ d ƒ t j d ƒ |  j ˆ  d g ƒ |  j t | ƒ d ƒ t j d ƒ |  j ˆ  d d g ƒ |  j t | ƒ d ƒ d  S(	   Ni   i    c           s   t  | ƒ ˆ  j |  ƒ g S(   N(   R   R$   (   t   itemt   seconds(   t   log(    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR0   h  s    R/   gš™™™™™¹?R‰   i   g333333Ã?(   R   R&   t   lenR#   R'   R   (   R   R   t   sleep_n_log(    (   R—   s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR   c  s    (   R   R   t   TrueR8   R   RS   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR”   `  s   c           c  s   d Vd Vt  j ‚ d  S(   Ni   i   (   R   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt
   error_iterw  s    t   TestErrorInIteratorc           B  s    e  Z e Z d  „  Z d „  Z RS(   c         C  sH   |  j  d ƒ |  _ |  j t j |  j j d „  t ƒ  ƒ t j d ƒ d  S(   Ni   c         S  s   d  S(   N(   R   (   RE   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR0   ƒ  s    gü©ñÒMbP?(	   R   R   R5   R   R   RM   R›   R'   R   (   R   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR     s    %c           sE   ˆ  j  d ƒ ˆ  _ ‡  f d †  } ˆ  j t j | ƒ t j d ƒ d  S(   Ni   c             s   t  ˆ  j j d „  t ƒ  ƒ ƒ S(   Nc         S  s   d  S(   N(   R   (   RE   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR0   Š  s    (   RL   R   Rz   R›   (    (   R   (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt	   unordered‰  s    gü©ñÒMbP?(   R   R   R5   R   R   R'   R   (   R   R   (    (   R   s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_unordered†  s    (   R   R   R7   R;   R   Rž   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyRœ   }  s   	t   TestMaxsizec           B  s#   e  Z d  „  Z e j d „  ƒ Z RS(   c         C  s£   |  j  d ƒ |  _ g  } t j |  j j | j d ƒ t j d |  j j | j d ƒ t j d ƒ |  j | g  ƒ d |  j _ t j d ƒ |  j	 | d d g ƒ d  S(   Ni    i   g{®Gáz„?i   g{®Gáz”?(
   R   R   R'   R#   R$   t   spawn_laterR   R&   t   maxsizeR)   (   R   t   done(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_inc’  s    c         C  s“   |  j  d ƒ } |  _ | j t d ƒ | j t d ƒ | j t d ƒ t j d ƒ |  j | j d ƒ d | _ t j d ƒ |  j | j d ƒ d  S(   Ni   gš™™™™™¹?gš™™™™™É?g333333Ó?i    (	   R   R   R#   R   R'   R&   R   R¡   R)   (   R   R   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_setzero   s    	(   R   R   R£   R   RS   R¤   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyRŸ     s   	t   TestSizec           B  s   e  Z e j ƒ  d  „  ƒ Z RS(   c         C  sý   |  j  d d t ƒ} |  _ |  j | j d ƒ d | _ |  j | j d ƒ d | _ |  j | j d ƒ d | _ |  j | j d ƒ |  j t ƒ  d | _ Wd  QX|  j t ƒ  d | _ Wd  QXd | _ |  j | j d ƒ d | _ |  j | j d ƒ d  S(   Ni   R   i    i   iÿÿÿÿi   (   R   R7   R   R&   R   R5   R9   (   R   R   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR   ¯  s     					(   R   R   R   t   reraises_flaky_race_conditionR   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR¥   ­  s   t   TestRefc           B  s   e  Z d  „  Z RS(   c      
   C  s  |  j  d ƒ } |  _ g  } t ƒ  } | | _ | j } ~ t ƒ  È | j | t ƒ  f i t ƒ  d 6ƒ } t | t ƒ sŠ t	 t
 | ƒ ƒ ‚ t j d ƒ | j t j | ƒ ƒ ~ ~ t rÐ t j ƒ  t j ƒ  n  x | D] } |  j | ƒ  ƒ q× W|  j d t | ƒ ƒ Wd  QXd  S(   Ni   t   kwarg1gš™™™™™¹?i   (   R   R   t	   SomeClasst   refsR=   R   R1   t   Objectt
   isinstanceRj   R]   R'   R   R$   t   weakreft   refR   R   R   t   assertIsNoneR&   R˜   (   R   R   Rª   t   objR=   R2   R+   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR   È  s$    			
%!
(   R   R   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR§   Æ  s   R«   c           B  s   e  Z RS(    (   R   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR«   ä  s   R©   c           B  s   e  Z d Z d d  „ Z RS(   c         C  sB   t  ƒ  } |  j j g  | | | g D] } t j | ƒ ^ q" ƒ | S(   N(   R«   Rª   t   extendR­   R®   (   R   t   arg1R¨   R2   RE   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR=   ì  s    	5N(   R   R   R   Rª   R=   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR©   è  s   c           C  s   d  S(   N(    (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   noopò  s    t   TestRefCountc           B  s   e  Z d  „  Z RS(   c         C  s7   |  j  d ƒ } | j t ƒ t j d ƒ | j ƒ  d  S(   Ni   i    (   R   R#   R³   R'   R   R   (   R   R   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR   ø  s    (   R   R   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR´   ö  s   t   ThreadPoolExecutor(   t   TimeoutError(   RF   (   t   as_completed(   t   monkeyt   TestTPEc           B  s\   e  Z d  Z e Z e j j Z e	 Z
 e j d „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z RS(   i   c   	        sÕ  |  j  t j d ƒ |  j ƒ |  j } g  ‰  d „  } d „  } | j | ƒ } d | _ | j | ƒ |  j t	 | j
 d d ƒd „  } t j | ƒ } |  j  | j
 ƒ  d ƒ |  j | j ƒ  ƒ |  j | j ƒ  ƒ t j ƒ  |  j  | j d	 ƒ |  j | j ƒ  ƒ |  j  | j d
 ƒ | j ‡  f d †  ƒ |  j  ˆ  t g ƒ t | f ƒ \ } } |  j  t | ƒ | g ƒ |  j  t t | f ƒ ƒ | g ƒ |  j  | j d	 ƒ t j ƒ  |  j  | j d	 ƒ | j ƒ  ~ ~ |  ` d  S(   Nt	   threadingc           S  s   t  j d ƒ d S(   Ng      à?i*   (   R'   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   fn  s    c         S  s"   |  j  d 7_  t j d ƒ ‚ d  S(   Ni   s   Expected, ignored(   t
   calledbackR   R   (   t   future(    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyRi     s    i    Rl   gü©ñÒMbP?c           S  s   d S(   Nià  (    (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   spawned$  s    i*   i   ià  c           s   ˆ  j  t ƒ S(   N(   R$   Rš   (   RN   (   R¼   (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR0   8  s    (   R&   R¸   t   is_module_patchedt   MONKEY_PATCHEDR   t   submitR¼   t   add_done_callbackR5   t   FutureTimeoutErrorR2   R'   R#   t
   assertTrueR¢   t   assertFalset	   cancelledR   t   readyt   valueRš   t   cf_waitRL   t   cf_as_completedR   (	   R   R   R»   Ri   R½   R¾   t   spawned_greenletR¢   t	   _not_done(    (   R¼   s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   test_future  s>    
					
"

c   
      C  s  |  j  t j d ƒ |  j ƒ |  j } d „  } | j | ƒ } |  j ré t | f d d ƒ\ } } |  j  t | ƒ | g ƒ d „  } t j	 | ƒ } t | f ƒ \ } }	 |  j  t | ƒ | g ƒ |  j
 | j ƒ  ƒ |  j  | j d ƒ n |  j t t | f ƒ | j ƒ  ~ ~ |  ` d  S(   NRº   c           S  s   t  j d ƒ d S(   Ng      à?i*   (   R'   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR»   S  s    Rl   gü©ñÒMbP?c           S  s   d S(   Nià  (    (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR¾   ]  s    ià  (   R&   R¸   R¿   RÀ   R   RÁ   RÉ   RL   R'   R#   RÄ   RÇ   RÈ   R5   t   AttributeErrorR   (
   R   R   R»   R½   t   _donet   not_doneR¾   RË   R¢   RÌ   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt    test_future_wait_module_functionK  s&    
				
c         C  sÀ   |  j  t j d ƒ |  j ƒ |  j } d „  } | j | ƒ } d „  } t j | ƒ } t j | f ƒ } |  j  t	 | ƒ | g ƒ |  j
 | j ƒ  ƒ |  j  | j d ƒ | j ƒ  ~ ~ |  ` d  S(   NRº   c           S  s   t  j d ƒ d S(   Ng      à?i*   (   R'   R   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR»   v  s    c           S  s   d S(   Nià  (    (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR¾   |  s    ià  (   R&   R¸   R¿   RÀ   R   RÁ   R'   R#   RF   RL   RÄ   RÇ   RÈ   R   (   R   R   R»   R½   R¾   RË   R¢   (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt    test_future_wait_gevent_functiono  s    
			
(   R   R   R   Rš   RP   R'   t
   threadpoolRµ   R   R7   RÀ   R   RS   RÍ   RÑ   RÒ   (    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyR¹     s   <$t   __main__(   gË¡E¶óý´?gìQ¸…ë¡?gìQ¸…ëÁ?(>   t
   __future__R    R   R   t
   contextlibRH   R­   R   t   gevent.testingt   testingR   R[   R'   R   R   R   t   contextmanagerR   R   R"   t   objectR<   RG   RI   Re   Rm   t   TIMEOUT3RJ   Rq   Rw   t   WINt   RUN_COVERAGER   RT   Rˆ   RS   R   RŽ   R   R”   R›   Rœ   RŸ   R¥   R§   R«   R©   R³   R´   t   hasattrRÓ   t   concurrent.futuresR¶   RÃ   RF   RÉ   R·   RÊ   R¸   R¹   R   t   main(    (    (    s<   lib/python2.7/site-packages/gevent/tests/test__threadpool.pyt   <module>   s`   "0	$	t			
	†