mò
­fIc           @   sË  d  Z  d k Z y d k Z Wn  e j
 o e i e =‚  n Xd k l Z l	 Z
 d k l Z d k l Z d d d d d	 d
 d d d d d d d d g Z e i Z e i Z e i Z e i Z [ e Z e o d e f d „  ƒ  YZ n d e f d „  ƒ  YZ d a d a  d „  Z! d „  Z" e Z# d „  Z$ d e f d „  ƒ  YZ% d „  Z& d e f d „  ƒ  YZ' d „  Z( d e f d  „  ƒ  YZ) d! „  Z* d" e) f d# „  ƒ  YZ+ d$ „  Z, d% e f d& „  ƒ  YZ- d' a. d( d) „ Z/ e ƒ  Z0 h  Z1 h  Z2 d e f d* „  ƒ  YZ3 d+ „  Z4 d, e3 f d- „  ƒ  YZ5 d. e3 f d/ „  ƒ  YZ6 d0 „  Z7 d1 e3 f d2 „  ƒ  YZ8 d3 „  Z9 d4 „  Z: d5 „  Z; e6 ƒ  y d6 k l< Z= Wn  e j
 o d7 k> l= Z= n Xd8 „  Z? e d9 j o e? ƒ  n d S(:   s;   Thread module emulating a subset of Java's threading model.N(   s   times   sleep(   s
   format_exc(   s   dequet   activeCountt	   Conditiont   currentThreadt	   enumeratet   Eventt   Lockt   RLockt	   Semaphoret   BoundedSemaphoret   Threadt   Timert
   setprofilet   settracet   localt   _Verbosec           B   s   t  Z d  d „ Z d „  Z RS(   Nc         C   s$   | d  j o
 t } n | |  _ d  S(   N(   t   verboset   Nonet   _VERBOSEt   selft   _Verbose__verbose(   R   R   (    (    t&   /mit/python/lib/python2.4/threading.pyt   __init__'   s    
c         G   sE   |  i o7 | | } d t ƒ  i ƒ  | f } t i i | ƒ n d  S(   Ns   %s: %s
(	   R   R   t   formatt   argsR   t   getNamet   _syst   stderrt   write(   R   R   R   (    (    R   t   _note,   s    

(   t   __name__t
   __module__R   R   R   (    (    (    R   R   %   s   c           B   s   t  Z d  d „ Z d „  Z RS(   Nc         C   s   d  S(   N(    (   R   R   (    (    R   R   6   s    c         G   s   d  S(   N(    (   R   R   (    (    R   R   8   s    (   R   R   R   R   R   (    (    (    R   R   5   s   c         C   s
   |  a d  S(   N(   t   funct   _profile_hook(   R   (    (    R   R   @   s     c         C   s
   |  a d  S(   N(   R   t   _trace_hook(   R   (    (    R   R   D   s     c          O   s   t  |  | Ž  S(   N(   t   _RLockR   t   kwargs(   R   R#   (    (    R   R   L   s    R"   c           B   sM   t  Z d  d „ Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 RS(	   Nc         C   s2   t  i |  | ƒ t ƒ  |  _ d  |  _ d |  _ d  S(   Ni    (	   R   R   R   R   t   _allocate_lockt   _RLock__blockR   t   _RLock__ownert   _RLock__count(   R   R   (    (    R   R   Q   s    	c         C   s-   d |  i i |  i o |  i i ƒ  |  i f S(   Ns   <%s(%s, %d)>(   R   t	   __class__R   R&   R   R'   (   R   (    (    R   t   __repr__W   s    i   c         C   s¾   t  ƒ  } |  i | j o6 |  i d |  _ t o |  i d |  | ƒ n d Sn |  i i	 | ƒ } | o4 | |  _ d |  _ t o |  i d |  | ƒ qº n t o |  i d |  | ƒ n | S(   Ni   s!   %s.acquire(%s): recursive successs   %s.acquire(%s): initial successs   %s.acquire(%s): failure(   R   t   meR   R&   R'   t	   __debug__R   t   blockingR%   t   acquiret   rc(   R   R,   R*   R.   (    (    R   R-   ]   s    			c         C   s’   t  ƒ  } |  i | j p
 t d ‚ |  i d |  _ } | p5 d  |  _ |  i i	 ƒ  t
 o |  i d |  ƒ qŽ n t
 o |  i d |  ƒ n d  S(   Ns   release() of un-acquire()d locki   s   %s.release(): final releases   %s.release(): non-final release(   R   R*   R   R&   t   AssertionErrorR'   t   countR   R%   t   releaseR+   R   (   R   R*   R0   (    (    R   R1   o   s    		c         C   sJ   | \ } } |  i i ƒ  | |  _ | |  _ t o |  i d |  ƒ n d  S(   Ns   %s._acquire_restore()(	   R0   t   ownerR   R%   R-   R'   R&   R+   R   (   R   t   .2R0   R2   (    (    R   t   _acquire_restore~   s
   		c         C   sV   t  o |  i d |  ƒ n |  i } d |  _ |  i } d  |  _ |  i i	 ƒ  | | f S(   Ns   %s._release_save()i    (
   R+   R   R   R'   R0   R&   R2   R   R%   R1   (   R   R0   R2   (    (    R   t   _release_save…   s    				c         C   s   |  i t ƒ  j S(   N(   R   R&   R   (   R   (    (    R   t	   _is_owned   s    (
   R   R   R   R   R)   R-   R1   R4   R5   R6   (    (    (    R   R"   O   s   				
c          O   s   t  |  | Ž  S(   N(   t
   _ConditionR   R#   (   R   R#   (    (    R   R   “   s    R7   c           B   s\   t  Z d  d  d „ Z d „  Z d „  Z d „  Z d „  Z d  d „ Z d d „ Z	 d	 „  Z
 RS(
   Nc         C   sÊ   t  i |  | ƒ | d  j o t ƒ  } n | |  _ | i |  _ | i	 |  _	 y | i
 |  _
 Wn t j
 o n Xy | i |  _ Wn t j
 o n Xy | i |  _ Wn t j
 o n Xg  |  _ d  S(   N(   R   R   R   R   t   lockR   R   t   _Condition__lockR-   R1   R5   t   AttributeErrorR4   R6   t   _Condition__waiters(   R   R8   R   (    (    R   R   ˜   s&    	c         C   s   d |  i t |  i ƒ f S(   Ns   <Condition(%s, %d)>(   R   R9   t   lenR;   (   R   (    (    R   R)   ±   s    c         C   s   |  i i ƒ  d  S(   N(   R   R9   R1   (   R   (    (    R   R5   ´   s    c         C   s   |  i i ƒ  d  S(   N(   R   R9   R-   (   R   t   x(    (    R   R4   ·   s    c         C   s0   |  i i d ƒ o |  i i ƒ  t Sn t Sd  S(   Ni    (   R   R9   R-   R1   t   Falset   True(   R   (    (    R   R6   º   s    c         C   s‚  |  i ƒ  p
 t d ‚ t ƒ  } | i ƒ  |  i i | ƒ |  i ƒ  } z'| d  j o) | i ƒ  t o |  i d |  ƒ qlnî t ƒ  | } d } xf t o^ | i d ƒ } | o Pn | t ƒ  } | d j o Pn t | d | d ƒ } t | ƒ q• W| pL t o |  i d |  | ƒ n y |  i i | ƒ Wqlt j
 o qlXn t o |  i d |  | ƒ n Wd  |  i | ƒ Xd  S(	   Ns   wait() of un-acquire()d locks   %s.wait(): got itf0.00050000000000000001i    i   f0.050000000000000003s   %s.wait(%s): timed outs   %s.wait(%s): got it(   R   R6   R/   R$   t   waiterR-   R;   t   appendR5   t   saved_statet   timeoutR   R+   R   t   _timet   endtimet   delayR?   t   gotitt	   remainingt   mint   _sleept   removet
   ValueErrorR4   (   R   RC   RF   RG   R@   RB   RE   RH   (    (    R   t   waitÃ   sB    	

 	 i   c         C   sÄ   |  i ƒ  p
 t d ‚ |  i } | |  } | p# t o |  i d |  ƒ n d  Sn |  i d |  | | d j o d p d ƒ x? | D]7 } | i	 ƒ  y | i
 | ƒ Wq… t j
 o q… Xq… Wd  S(   Ns   notify() of un-acquire()d locks   %s.notify(): no waiterss"   %s.notify(): notifying %d waiter%si   t   st    (   R   R6   R/   R;   t   nt   waitersR+   R   R@   R1   RK   RL   (   R   RP   R@   R;   RQ   (    (    R   t   notifyì   s     	
 
c         C   s   |  i t |  i ƒ ƒ d  S(   N(   R   RR   R<   R;   (   R   (    (    R   t	   notifyAllý   s    (   R   R   R   R   R)   R5   R4   R6   RM   RR   RS   (    (    (    R   R7   –   s   					)c          O   s   t  |  | Ž  S(   N(   t
   _SemaphoreR   R#   (   R   R#   (    (    R   R     s    RT   c           B   s,   t  Z d d  d „ Z d d „ Z d „  Z RS(   Ni   c         C   sF   | d j p
 t d ‚ t i |  | ƒ t t ƒ  ƒ |  _ | |  _	 d  S(   Ni    s$   Semaphore initial value must be >= 0(
   t   valueR/   R   R   R   R   R   R   t   _Semaphore__condt   _Semaphore__value(   R   RU   R   (    (    R   R     s    c         C   s°   t  } |  i i ƒ  x‰ |  i d j oA | p Pn t o |  i d |  | |  i ƒ n |  i i	 ƒ  q W|  i d |  _ t o |  i d |  |  i ƒ n t
 } |  i i ƒ  | S(   Ni    s)   %s.acquire(%s): blocked waiting, value=%si   s   %s.acquire: success, value=%s(   R>   R.   R   RV   R-   RW   R,   R+   R   RM   R?   R1   (   R   R,   R.   (    (    R   R-     s"     		c         C   s\   |  i i ƒ  |  i d |  _ t o |  i d |  |  i ƒ n |  i i ƒ  |  i i ƒ  d  S(   Ni   s   %s.release: success, value=%s(   R   RV   R-   RW   R+   R   RR   R1   (   R   (    (    R   R1   !  s    	(   R   R   R   R   R-   R1   (    (    (    R   RT     s   c          O   s   t  |  | Ž  S(   N(   t   _BoundedSemaphoreR   R#   (   R   R#   (    (    R   R   +  s    RX   c           B   s&   t  Z d  Z d e d „ Z d „  Z RS(   s6   Semaphore that checks that # releases is <= # acquiresi   c         C   s    t  i |  | | ƒ | |  _ d  S(   N(   RT   R   R   RU   R   t   _initial_value(   R   RU   R   (    (    R   R   0  s    c         C   s-   |  i |  i j o t d ‚ n t i |  ƒ S(   Ns!   Semaphore released too many times(   R   RW   RY   RL   RT   R1   (   R   (    (    R   R1   4  s    (   R   R   t   __doc__R   R   R1   (    (    (    R   RX   .  s    c          O   s   t  |  | Ž  S(   N(   t   _EventR   R#   (   R   R#   (    (    R   R   :  s    R[   c           B   s;   t  Z d  d „ Z d „  Z d „  Z d „  Z d  d „ Z RS(   Nc         C   s/   t  i |  | ƒ t t ƒ  ƒ |  _ t |  _ d  S(   N(	   R   R   R   R   R   R   t   _Event__condR>   t   _Event__flag(   R   R   (    (    R   R   A  s    c         C   s   |  i S(   N(   R   R]   (   R   (    (    R   t   isSetF  s    c         C   s<   |  i i ƒ  z t |  _ |  i i ƒ  Wd  |  i i ƒ  Xd  S(   N(   R   R\   R-   R?   R]   RS   R1   (   R   (    (    R   t   setI  s    	 c         C   s/   |  i i ƒ  z t |  _ Wd  |  i i ƒ  Xd  S(   N(   R   R\   R-   R>   R]   R1   (   R   (    (    R   t   clearQ  s
     c         C   sD   |  i i ƒ  z" |  i p |  i i | ƒ n Wd  |  i i ƒ  Xd  S(   N(   R   R\   R-   R]   RM   RC   R1   (   R   RC   (    (    R   RM   X  s    
 (   R   R   R   R   R^   R_   R`   RM   (    (    (    R   R[   =  s
   			i    s	   Thread-%dc         C   s   t  d a  |  t  S(   Ni   (   t   _countert   template(   Rb   (    (    R   t   _newnameb  s     
c           B   sª   t  Z e Z e i Z d  d  d  f  h  d  d „ Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d  d	 „ Z d
 „  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s§   | d  j p
 t d ‚ t i |  | ƒ | |  _ t	 | p t ƒ  ƒ |  _ | |  _ | |  _ |  i ƒ  |  _ t |  _ t |  _ t t ƒ  ƒ |  _ t |  _ t i |  _ d  S(   Ns#   group argument must be None for now(   t   groupR   R/   R   R   R   R   t   targett   _Thread__targett   strt   nameRc   t   _Thread__nameR   t   _Thread__argsR#   t   _Thread__kwargst   _set_daemont   _Thread__daemonicR>   t   _Thread__startedt   _Thread__stoppedR   R   t   _Thread__blockR?   t   _Thread__initializedR   R   t   _Thread__stderr(   R   Rd   Re   Rh   R   R#   R   (    (    R   R   x  s    						c         C   s   t  ƒ  i ƒ  S(   N(   R   t   isDaemon(   R   (    (    R   Rl   ‰  s    c         C   st   |  i p
 t d ‚ d } |  i o
 d } n |  i o
 d } n |  i o | d } n d |  i i |  i	 | f S(   Ns    Thread.__init__() was not calledt   initialt   startedt   stoppeds    daemons   <%s(%s, %s)>(
   R   Rq   R/   t   statusRn   Ro   Rm   R(   R   Ri   (   R   Rw   (    (    R   R)     s    




c         C   s‰   |  i p
 t d ‚ |  i p
 t d ‚ t o |  i d |  ƒ n t i ƒ  |  t |  <t i	 ƒ  t
 |  i f  ƒ t |  _ t d ƒ d  S(   Ns   Thread.__init__() not calleds   thread already starteds   %s.start(): starting threadf9.9999999999999995e-07(   R   Rq   R/   Rn   R+   R   t   _active_limbo_lockR-   t   _limboR1   t   _start_new_threadt   _Thread__bootstrapR?   RJ   (   R   (    (    R   t   start˜  s    


	c         C   s(   |  i o |  i |  i |  i Ž  n d  S(   N(   R   Rf   Rj   Rk   (   R   (    (    R   t   run¤  s    
c      
   C   s  zõt  |  _ t i ƒ  |  t t ƒ  <t |  =t i ƒ  t	 o |  i
 d |  ƒ n t o! |  i
 d |  ƒ t i t ƒ n t o! |  i
 d |  ƒ t i t ƒ n y |  i ƒ  Wn)t j
 o" t	 o |  i
 d |  ƒ qônt	 o |  i
 d |  ƒ n t o' t i i d |  i ƒ  t ƒ  f ƒ qô|  i ƒ  \ } } } zŠ |  i d |  i ƒ  d IJ|  i d	 IJxD | o< |  i d
 | i i i | i | i i i f IJ| i  } qlW|  i d | | f IJWd  ~ ~ ~ Xn Xt	 o |  i
 d |  ƒ n Wd  |  i! ƒ  y |  i" ƒ  Wn n XXd  S(   Ns    %s.__bootstrap(): thread starteds(   %s.__bootstrap(): registering trace hooks*   %s.__bootstrap(): registering profile hooks#   %s.__bootstrap(): raised SystemExits%   %s.__bootstrap(): unhandled exceptions   Exception in thread %s:
%s
s   Exception in thread s2    (most likely raised during interpreter shutdown):s"   Traceback (most recent call last):s     File "%s", line %s, in %ss   %s: %ss   %s.__bootstrap(): normal return(#   R?   R   Rn   Rx   R-   t   _activet
   _get_identRy   R1   R+   R   R!   R   R   R    R   R}   t
   SystemExitR   R   R   t   _format_exct   _Thread__exc_infot   exc_typet	   exc_valuet   exc_tbRr   t   tb_framet   f_codet   co_filenamet	   tb_linenot   co_namet   tb_nextt   _Thread__stopt   _Thread__delete(   R   R„   Rƒ   R…   (    (    R   t   __bootstrap¨  sV    	

' /  
c         C   s4   |  i i ƒ  t |  _ |  i i ƒ  |  i i ƒ  d  S(   N(   R   Rp   R-   R?   Ro   RS   R1   (   R   (    (    R   t   __stopé  s    	c         C   s[   t  i ƒ  z? y t t ƒ  =Wn* t j
 o d t i j o ‚  qH n XWd t  i ƒ  Xd S(   sA   Remove current thread from the dict of currently running threads.t   dummy_threadingN(   Rx   R-   R~   R   t   KeyErrorR   t   modulesR1   (   R   (    (    R   t   __deleteï  s     
 c         C   s`  |  i p
 t d ‚ |  i p
 t d ‚ |  t ƒ  j	 p
 t d ‚ t o" |  i p |  i d |  ƒ qk n |  i i	 ƒ  zÓ | d  j o> x |  i p |  i i ƒ  q‹ Wt o |  i d |  ƒ qJn… t ƒ  | } xt |  i pN | t ƒ  } | d j o  t o |  i d |  ƒ n Pn |  i i | ƒ qÖ Wt o |  i d |  ƒ n Wd  |  i i ƒ  Xd  S(   Ns   Thread.__init__() not calleds'   cannot join thread before it is starteds   cannot join current threads%   %s.join(): waiting until thread stopss   %s.join(): thread stoppedi    s   %s.join(): timed out(   R   Rq   R/   Rn   R   R+   Ro   R   Rp   R-   RC   R   RM   RD   t   deadlineRF   R1   (   R   RC   RF   R”   (    (    R   t   join  s6    
 
 
 c         C   s   |  i p
 t d ‚ |  i S(   Ns   Thread.__init__() not called(   R   Rq   R/   Ri   (   R   (    (    R   R   .  s    c         C   s'   |  i p
 t d ‚ t | ƒ |  _ d  S(   Ns   Thread.__init__() not called(   R   Rq   R/   Rg   Rh   Ri   (   R   Rh   (    (    R   t   setName2  s    c         C   s&   |  i p
 t d ‚ |  i o |  i S(   Ns   Thread.__init__() not called(   R   Rq   R/   Rn   Ro   (   R   (    (    R   t   isAlive6  s    c         C   s   |  i p
 t d ‚ |  i S(   Ns   Thread.__init__() not called(   R   Rq   R/   Rm   (   R   (    (    R   Rs   :  s    c         C   s6   |  i p
 t d ‚ |  i p
 t d ‚ | |  _ d  S(   Ns   Thread.__init__() not calleds)   cannot set daemon status of active thread(   R   Rq   R/   Rn   t   daemonicRm   (   R   R˜   (    (    R   t	   setDaemon>  s    (   R   R   R>   Rq   R   t   exc_infoR‚   R   R   Rl   R)   R|   R}   R{   RŒ   R   R•   R   R–   R—   Rs   R™   (    (    (    R   R	   o  s    						A		"				c          O   s   t  |  | Ž  S(   N(   t   _TimerR   R#   (   R   R#   (    (    R   R
   E  s    R›   c           B   s/   t  Z d  Z g  h  d „ Z d „  Z d „  Z RS(   s²   Call a function after a specified number of seconds:

    t = Timer(30.0, f, args=[], kwargs={})
    t.start()
    t.cancel() # stop the timer's action if it's still waiting
    c         C   sA   t  i |  ƒ | |  _ | |  _ | |  _ | |  _ t ƒ  |  _ d  S(   N(	   R	   R   R   t   intervalt   functionR   R#   R   t   finished(   R   Rœ   R   R   R#   (    (    R   R   P  s    				c         C   s   |  i i ƒ  d S(   s(   Stop the timer if it hasn't finished yetN(   R   Rž   R_   (   R   (    (    R   t   cancelX  s     c         C   sN   |  i i |  i ƒ |  i i ƒ  p |  i |  i |  i Ž  n |  i i ƒ  d  S(   N(	   R   Rž   RM   Rœ   R^   R   R   R#   R_   (   R   (    (    R   R}   \  s    (   R   R   RZ   R   RŸ   R}   (    (    (    R   R›   H  s    	t   _MainThreadc           B   s#   t  Z d „  Z d „  Z d „  Z RS(   Nc         C   sZ   t  i |  d d ƒt |  _ t i ƒ  |  t t ƒ  <t i	 ƒ  d  k
 } | i |  i ƒ d  S(   NRh   t
   MainThread(   R	   R   R   R?   Rn   Rx   R-   R~   R   R1   t   atexitt   registert   _MainThread__exitfunc(   R   R¢   (    (    R   R   g  s    	

	c         C   s   t  S(   N(   R>   (   R   (    (    R   Rl   p  s    c         C   s„   |  i ƒ  t ƒ  } | o t o |  i d |  ƒ q9 n x | o | i ƒ  t ƒ  } q< Wt o |  i d |  ƒ n |  i ƒ  d  S(   Ns   %s: waiting for other threadss   %s: exiting(   R   RŒ   t   _pickSomeNonDaemonThreadt   tR+   R   R•   R   (   R   R¦   (    (    R   t
   __exitfuncs  s    
	 
(   R   R   R   Rl   R¤   (    (    (    R   R    e  s   			c          C   s;   x4 t  ƒ  D]) }  |  i ƒ  o |  i ƒ  o |  Sq
 q
 Wd  S(   N(   R   R¦   Rs   R—   R   (   R¦   (    (    R   R¥   €  s
    
 t   _DummyThreadc           B   s&   t  Z d „  Z d „  Z d  d „ Z RS(   Nc         C   sG   t  i |  d t d ƒ ƒt |  _ t i ƒ  |  t t	 ƒ  <t i
 ƒ  d  S(   NRh   s   Dummy-%d(   R	   R   R   Rc   R?   Rn   Rx   R-   R~   R   R1   (   R   (    (    R   R     s
    	
c         C   s   t  S(   N(   R?   (   R   (    (    R   Rl   —  s    c         C   s   t  p
 t d ‚ d  S(   Ns   cannot join a dummy thread(   R>   R/   (   R   RC   (    (    R   R•   š  s    (   R   R   R   Rl   R   R•   (    (    (    R   R¨   Ž  s   		c           C   s0   y t  t ƒ  SWn t j
 o t ƒ  Sn Xd  S(   N(   R~   R   R‘   R¨   (    (    (    R   R      s    c          C   s.   t  i ƒ  t t ƒ t t ƒ }  t  i ƒ  |  S(   N(   Rx   R-   R<   R~   Ry   R0   R1   (   R0   (    (    R   R    §  s    

c          C   s.   t  i ƒ  t i ƒ  t i ƒ  }  t  i ƒ  |  S(   N(   Rx   R-   R~   t   valuesRy   t   activeR1   (   Rª   (    (    R   R   ­  s    

(   s   _local(   s   localc          C   s  d t  f d „  ƒ  Y} d t f d „  ƒ  Y} d t f d „  ƒ  Y} d }	 d }
 d	 }  | |
 ƒ } g  } xE t
 |	 ƒ D]7 } | | |  ƒ } | i d
 | d ƒ | i | ƒ qs W| | |  |	 ƒ } x" | D] } | i ƒ  t d ƒ qÈ W| i ƒ  x | D] } | i ƒ  q÷ W| i ƒ  d  S(   Nt   BoundedQueuec           B   s#   t  Z d „  Z d „  Z d „  Z RS(   Nc         C   sV   t  i |  ƒ t ƒ  |  _ t |  i ƒ |  _ t |  i ƒ |  _ | |  _ t	 ƒ  |  _
 d  S(   N(   R   R   R   R   t   monR   R.   t   wct   limitt   dequet   queue(   R   R®   (    (    R   R   Æ  s    	c         C   s•   |  i i ƒ  x; t |  i ƒ |  i j o! |  i d | ƒ |  i i	 ƒ  q W|  i i
 | ƒ |  i d | t |  i ƒ ƒ |  i i ƒ  |  i i ƒ  d  S(   Ns   put(%s): queue fulls    put(%s): appended, length now %d(   R   R¬   R-   R<   R°   R®   R   t   itemR­   RM   RA   R.   RR   R1   (   R   R±   (    (    R   t   putÎ  s     	c         C   s‚   |  i i ƒ  x) |  i p |  i d ƒ |  i i ƒ  q W|  i i ƒ  } |  i d | t	 |  i ƒ ƒ |  i
 i ƒ  |  i i ƒ  | S(   Ns   get(): queue emptys   get(): got %s, %d left(   R   R¬   R-   R°   R   R.   RM   t   popleftR±   R<   R­   RR   R1   (   R   R±   (    (    R   t   getÙ  s     
(   R   R   R   R²   R´   (    (    (    R   R«   Ä  s   		t   ProducerThreadc           B   s   t  Z d „  Z d „  Z RS(   Nc         C   s)   t  i |  d d ƒ| |  _ | |  _ d  S(   NRh   t   Producer(   R	   R   R   R°   t   quota(   R   R°   R·   (    (    R   R   æ  s    	c         C   sj   d k  l  } d } xP | |  i j  o? | d } |  i i d |  i ƒ  | f ƒ t | ƒ  d ƒ q Wd  S(   N(   s   randomi    i   s   %s.%df1.0000000000000001e-05(   t   randomt   counterR   R·   R°   R²   R   RJ   (   R   R¸   R¹   (    (    R   R}   ë  s     
 (   R   R   R   R}   (    (    (    R   Rµ   ä  s   	t   ConsumerThreadc           B   s   t  Z d „  Z d „  Z RS(   Nc         C   s)   t  i |  d d ƒ| |  _ | |  _ d  S(   NRh   t   Consumer(   R	   R   R   R°   R0   (   R   R°   R0   (    (    R   R   ö  s    	c         C   s@   x9 |  i d j o( |  i i ƒ  } | GH|  i d |  _ q Wd  S(   Ni    i   (   R   R0   R°   R´   R±   (   R   R±   (    (    R   R}   û  s
     (   R   R   R   R}   (    (    (    R   Rº   ô  s   	i   i   i   s   Producer-%di   f9.9999999999999995e-07(   R   R«   R	   Rµ   Rº   t   NPt   QLt   NIt   Qt   Pt   ranget   iR¦   R–   RA   t   CR|   RJ   R•   (   R¾   RÃ   Rµ   RÂ   R«   RÀ   Rº   R¿   R¦   R¼   R½   (    (    R   t   _testÂ  s.       

 t   __main__(@   RZ   t   sysR   t   threadt   ImportErrorR’   R   t   timeRD   t   sleepRJ   t	   tracebackt
   format_excR   t   collectionsR¯   t   __all__t   start_new_threadRz   t   allocate_lockR$   t	   get_identR   t   errort   ThreadErrorR>   R   R+   t   objectR   R   R    R!   R   R   R   R   R"   R   R7   R   RT   R   RX   R   R[   Ra   Rc   Rx   R~   Ry   R	   R
   R›   R    R¥   R¨   R   R    R   t   _localR   t   _threading_localRÄ   ()   RX   R   R   R   R    RJ   RÓ   Rz   R   RÎ   R[   R›   R"   RÄ   R   Rx   R   R   R¯   R   R¨   R	   R7   R   R   R   R   R
   RT   Rc   RÇ   R¥   Ry   R   R~   R    R   RD   R$   R   R   (    (    R   t   ?   sp   	
0								D	k	'		$	Ö						R