Ñò
ïžòKc           @   s-  d  Z  d d k Z y d d k Z Wn  e j
 o e i e =‚  n Xd d k Z d d k l	 Z	 d d k
 l
 Z l Z d d k l Z d d k l Z d d d	 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 i d d e d d d d ƒe Z d e  f d „  ƒ  YZ! e" a# e" 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. „  Z0 d/ e! f d0 „  ƒ  YZ1 d1 a2 d2 d3 „ Z3 e ƒ  a4 h  Z5 h  Z6 d e! f d4 „  ƒ  YZ7 d5 „  Z8 d6 e7 f d7 „  ƒ  YZ9 d8 e7 f d9 „  ƒ  YZ: d: „  Z; d; e7 f d< „  ƒ  YZ< d= „  Z= e= Z> d> „  Z? e? Z@ d? „  ZA d d@ k lB ZB e: ƒ  iC ZD y d dA k lE ZF Wn# e j
 o d dB kG lF ZF n XdC „  ZH dD „  ZI e dE j o eI ƒ  n d S(F   s;   Thread module emulating a subset of Java's threading model.iÿÿÿÿN(   t   wraps(   t   timet   sleep(   t
   format_exc(   t   dequet   activeCountt   active_countt	   Conditiont   currentThreadt   current_threadt	   enumeratet   Eventt   Lockt   RLockt	   Semaphoret   BoundedSemaphoret   Threadt   Timert
   setprofilet   settracet   localt
   stack_sizet   ignoret   categoryt   modulet	   threadingt   messages   sys.exc_cleart   _Verbosec           B   s   e  Z d d  „ Z d „  Z RS(   c         C   s$   | d  j o
 t } n | |  _ d  S(   N(   t   Nonet   _VERBOSEt   _Verbose__verbose(   t   selft   verbose(    (    s   scripts/common/Lib/threading.pyt   __init__;   s    
c         G   sB   |  i  o4 | | } d t ƒ  i | f } t i i | ƒ n d  S(   Ns   %s: %s
(   R   R	   t   namet   _syst   stderrt   write(   R   t   formatt   args(    (    s   scripts/common/Lib/threading.pyt   _note@   s
    

N(   t   __name__t
   __module__R   R!   R(   (    (    (    s   scripts/common/Lib/threading.pyR   9   s   c         C   s
   |  a  d  S(   N(   t   _profile_hook(   t   func(    (    s   scripts/common/Lib/threading.pyR   T   s    c         C   s
   |  a  d  S(   N(   t   _trace_hook(   R,   (    (    s   scripts/common/Lib/threading.pyR   X   s    c          O   s   t  |  | Ž  S(   N(   t   _RLock(   R'   t   kwargs(    (    s   scripts/common/Lib/threading.pyR   `   s    R.   c           B   s\   e  Z d	 d  „ Z d „  Z d d „ Z e Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(
   c         C   s2   t  i |  | ƒ t ƒ  |  _ d  |  _ d |  _ d  S(   Ni    (   R   R!   t   _allocate_lockt   _RLock__blockR   t   _RLock__ownert   _RLock__count(   R   R    (    (    s   scripts/common/Lib/threading.pyR!   e   s    	c         C   s-   |  i  } d |  i i | o | i |  i f S(   Ns   <%s(%s, %d)>(   R2   t	   __class__R)   R"   R3   (   R   t   owner(    (    s   scripts/common/Lib/threading.pyt   __repr__k   s
    		i   c         C   sš   t  ƒ  } |  i | j o( |  i d |  _ |  i d |  | ƒ d S|  i i | ƒ } | o) | |  _ d |  _ |  i d |  | ƒ n |  i d |  | ƒ | S(   Ni   s!   %s.acquire(%s): recursive successs   %s.acquire(%s): initial successs   %s.acquire(%s): failure(   R	   R2   R3   R(   R1   t   acquire(   R   t   blockingt   met   rc(    (    s   scripts/common/Lib/threading.pyR7   r   s    			c         C   s|   |  i  t ƒ  j	 o t d ƒ ‚ n |  i d |  _ } | p* d  |  _  |  i i ƒ  |  i d |  ƒ n |  i d |  ƒ d  S(   Ns   cannot release un-aquired locki   s   %s.release(): final releases   %s.release(): non-final release(   R2   R	   t   RuntimeErrorR3   R   R1   t   releaseR(   (   R   t   count(    (    s   scripts/common/Lib/threading.pyR<   †   s    	c         C   s   |  i  ƒ  d  S(   N(   R<   (   R   t   tt   vt   tb(    (    s   scripts/common/Lib/threading.pyt   __exit__“   s    c         C   s?   | \ } } |  i  i ƒ  | |  _ | |  _ |  i d |  ƒ d  S(   Ns   %s._acquire_restore()(   R1   R7   R3   R2   R(   (   R   t   count_ownerR=   R5   (    (    s   scripts/common/Lib/threading.pyt   _acquire_restore˜   s
    		c         C   sK   |  i  d |  ƒ |  i } d |  _ |  i } d  |  _ |  i i ƒ  | | f S(   Ns   %s._release_save()i    (   R(   R3   R2   R   R1   R<   (   R   R=   R5   (    (    s   scripts/common/Lib/threading.pyt   _release_save    s    				c         C   s   |  i  t ƒ  j S(   N(   R2   R	   (   R   (    (    s   scripts/common/Lib/threading.pyt	   _is_ownedª   s    N(   R)   R*   R   R!   R6   R7   t	   __enter__R<   RA   RC   RD   RE   (    (    (    s   scripts/common/Lib/threading.pyR.   c   s   					
c          O   s   t  |  | Ž  S(   N(   t
   _Condition(   R'   R/   (    (    s   scripts/common/Lib/threading.pyR   ®   s    RG   c           B   st   e  Z d d d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d d „ Z
 d d	 „ Z d
 „  Z e Z RS(   c         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   _Condition__lockR7   R<   RD   t   AttributeErrorRC   RE   t   _Condition__waiters(   R   t   lockR    (    (    s   scripts/common/Lib/threading.pyR!   ³   s&    	c         C   s   |  i  i ƒ  S(   N(   RH   RF   (   R   (    (    s   scripts/common/Lib/threading.pyRF   Ì   s    c         G   s   |  i  i | Œ  S(   N(   RH   RA   (   R   R'   (    (    s   scripts/common/Lib/threading.pyRA   Ï   s    c         C   s   d |  i  t |  i ƒ f S(   Ns   <Condition(%s, %d)>(   RH   t   lenRJ   (   R   (    (    s   scripts/common/Lib/threading.pyR6   Ò   s    c         C   s   |  i  i ƒ  d  S(   N(   RH   R<   (   R   (    (    s   scripts/common/Lib/threading.pyRD   Õ   s    c         C   s   |  i  i ƒ  d  S(   N(   RH   R7   (   R   t   x(    (    s   scripts/common/Lib/threading.pyRC   Ø   s    c         C   s-   |  i  i d ƒ o |  i  i ƒ  t St Sd  S(   Ni    (   RH   R7   R<   t   Falset   True(   R   (    (    s   scripts/common/Lib/threading.pyRE   Û   s    c      	   C   sg  |  i  ƒ  p t d ƒ ‚ n t ƒ  } | i ƒ  |  i i | ƒ |  i ƒ  } z| d  j o | i ƒ  |  i d |  ƒ nØ t	 ƒ  | } d } xf t
 o^ | i d ƒ } | o Pn | t	 ƒ  } | d j o Pn t | d | d ƒ } t | ƒ q� W| pA |  i d |  | ƒ y |  i i | ƒ WqQt j
 o qQXn |  i d |  | ƒ Wd  |  i | ƒ Xd  S(	   Ns   cannot wait on un-aquired locks   %s.wait(): got itgü©ñÒMb@?i    i   gš™™™™™©?s   %s.wait(%s): timed outs   %s.wait(%s): got it(   RE   R;   R0   R7   RJ   t   appendRD   R   R(   t   _timeRO   t   mint   _sleept   removet
   ValueErrorRC   (   R   t   timeoutt   waitert   saved_statet   endtimet   delayt   gotitt	   remaining(    (    s   scripts/common/Lib/threading.pyt   waitä   s<    	

 	i   c         C   s¼   |  i  ƒ  p t d ƒ ‚ n |  i } | |  } | p |  i d |  ƒ d  S|  i d |  | | d j o d p d ƒ x? | D]7 } | i ƒ  y | i | ƒ Wq} t j
 o q} Xq} Wd  S(   Ns    cannot notify on un-aquired locks   %s.notify(): no waiterss"   %s.notify(): notifying %d waiter%si   t   st    (   RE   R;   RJ   R(   R<   RT   RU   (   R   t   nRJ   t   waitersRW   (    (    s   scripts/common/Lib/threading.pyt   notify  s     	
 
c         C   s   |  i  t |  i ƒ ƒ d  S(   N(   Rb   RL   RJ   (   R   (    (    s   scripts/common/Lib/threading.pyt	   notifyAll   s    N(   R)   R*   R   R!   RF   RA   R6   RD   RC   RE   R]   Rb   Rc   t
   notify_all(    (    (    s   scripts/common/Lib/threading.pyRG   ±   s   							*	c          O   s   t  |  | Ž  S(   N(   t
   _Semaphore(   R'   R/   (    (    s   scripts/common/Lib/threading.pyR   &  s    Re   c           B   s;   e  Z d  d d „ Z d  d „ Z e Z d „  Z d „  Z RS(   i   c         C   sL   | d j  o t  d ƒ ‚ n t i |  | ƒ t t ƒ  ƒ |  _ | |  _ d  S(   Ni    s$   semaphore initial value must be >= 0(   RU   R   R!   R   R   t   _Semaphore__condt   _Semaphore__value(   R   t   valueR    (    (    s   scripts/common/Lib/threading.pyR!   -  s
    c         C   sš   t  } |  i i ƒ  xs |  i d j o6 | p Pn |  i d |  | |  i ƒ |  i i ƒ  q W|  i d |  _ |  i d |  |  i ƒ t } |  i i ƒ  | S(   Ni    s)   %s.acquire(%s): blocked waiting, value=%si   s   %s.acquire: success, value=%s(   RN   Rf   R7   Rg   R(   R]   RO   R<   (   R   R8   R:   (    (    s   scripts/common/Lib/threading.pyR7   4  s     		c         C   sQ   |  i  i ƒ  |  i d |  _ |  i d |  |  i ƒ |  i  i ƒ  |  i  i ƒ  d  S(   Ni   s   %s.release: success, value=%s(   Rf   R7   Rg   R(   Rb   R<   (   R   (    (    s   scripts/common/Lib/threading.pyR<   I  s    	c         C   s   |  i  ƒ  d  S(   N(   R<   (   R   R>   R?   R@   (    (    s   scripts/common/Lib/threading.pyRA   R  s    N(   R)   R*   R   R!   R7   RF   R<   RA   (    (    (    s   scripts/common/Lib/threading.pyRe   )  s
   		c          O   s   t  |  | Ž  S(   N(   t   _BoundedSemaphore(   R'   R/   (    (    s   scripts/common/Lib/threading.pyR   V  s    Ri   c           B   s&   e  Z d  Z d d d „ Z d „  Z RS(   s6   Semaphore that checks that # releases is <= # acquiresi   c         C   s    t  i |  | | ƒ | |  _ d  S(   N(   Re   R!   t   _initial_value(   R   Rh   R    (    (    s   scripts/common/Lib/threading.pyR!   [  s    c         C   s-   |  i  |  i j o t d ‚ n t i |  ƒ S(   Ns!   Semaphore released too many times(   Rg   Rj   RU   Re   R<   (   R   (    (    s   scripts/common/Lib/threading.pyR<   _  s    N(   R)   R*   t   __doc__R   R!   R<   (    (    (    s   scripts/common/Lib/threading.pyRi   Y  s   c          O   s   t  |  | Ž  S(   N(   t   _Event(   R'   R/   (    (    s   scripts/common/Lib/threading.pyR   e  s    Rl   c           B   sA   e  Z d d  „ Z d „  Z e Z d „  Z d „  Z d d „ Z RS(   c         C   s/   t  i |  | ƒ t t ƒ  ƒ |  _ t |  _ d  S(   N(   R   R!   R   R   t   _Event__condRN   t   _Event__flag(   R   R    (    (    s   scripts/common/Lib/threading.pyR!   l  s    c         C   s   |  i  S(   N(   Rn   (   R   (    (    s   scripts/common/Lib/threading.pyt   isSetq  s    c         C   s<   |  i  i ƒ  z t |  _ |  i  i ƒ  Wd  |  i  i ƒ  Xd  S(   N(   Rm   R7   RO   Rn   Rd   R<   (   R   (    (    s   scripts/common/Lib/threading.pyt   setv  s
    	c         C   s/   |  i  i ƒ  z t |  _ Wd  |  i  i ƒ  Xd  S(   N(   Rm   R7   RN   Rn   R<   (   R   (    (    s   scripts/common/Lib/threading.pyt   clear~  s    c         C   sD   |  i  i ƒ  z" |  i p |  i  i | ƒ n Wd  |  i  i ƒ  Xd  S(   N(   Rm   R7   Rn   R]   R<   (   R   RV   (    (    s   scripts/common/Lib/threading.pyR]   …  s
    
N(	   R)   R*   R   R!   Ro   t   is_setRp   Rq   R]   (    (    (    s   scripts/common/Lib/threading.pyRl   h  s   			i    s	   Thread-%dc         C   s   t  d a  |  t  S(   Ni   (   t   _counter(   t   template(    (    s   scripts/common/Lib/threading.pyt   _newname�  s    
c           B   s  e  Z e Z e i Z e i Z d d d d d d d  „ Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d	 „  Z d d
 „ Z e d „  ƒ Z e i d „  ƒ Z e d „  ƒ Z d „  Z e Z e d „  ƒ Z e i d „  ƒ Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sÊ   | d  j p
 t d ‚ t i |  | ƒ | d  j o
 h  } n | |  _ t | p t ƒ  ƒ |  _ | |  _ | |  _	 |  i
 ƒ  |  _ d  |  _ t ƒ  |  _ t |  _ t t ƒ  ƒ |  _ t |  _ t i |  _ d  S(   Ns#   group argument must be None for now(   R   t   AssertionErrorR   R!   t   _Thread__targett   strRu   t   _Thread__namet   _Thread__argst   _Thread__kwargst   _set_daemont   _Thread__daemonict   _Thread__identR   t   _Thread__startedRN   t   _Thread__stoppedR   R   t   _Thread__blockRO   t   _Thread__initializedR#   R$   t   _Thread__stderr(   R   t   groupt   targetR"   R'   R/   R    (    (    s   scripts/common/Lib/threading.pyR!   ¨  s    
						c         C   s
   t  ƒ  i S(   N(   R	   t   daemon(   R   (    (    s   scripts/common/Lib/threading.pyR|   ¼  s    c         C   sŸ   |  i  p
 t d ‚ d } |  i i ƒ  o
 d } n |  i o
 d } n |  i o | d 7} n |  i d  j	 o | d |  i 7} n d |  i i	 |  i
 | f S(   Ns    Thread.__init__() was not calledt   initialt   startedt   stoppeds    daemons    %ss   <%s(%s, %s)>(   R‚   Rv   R   Rr   R€   R}   R~   R   R4   R)   Ry   (   R   t   status(    (    s   scripts/common/Lib/threading.pyR6   À  s    



c         C   s‰   |  i  p t d ƒ ‚ n |  i i ƒ  o t d ƒ ‚ n |  i d |  ƒ t i ƒ  |  t |  <t i ƒ  t	 |  i
 d ƒ |  i i ƒ  d  S(   Ns   thread.__init__() not calleds   thread already starteds   %s.start(): starting thread(    (   R‚   R;   R   Rr   R(   t   _active_limbo_lockR7   t   _limboR<   t   _start_new_threadt   _Thread__bootstrapR]   (   R   (    (    s   scripts/common/Lib/threading.pyt   startÍ  s    



c         C   sB   z( |  i  o |  i  |  i |  i Ž  n Wd  |  `  |  ` |  ` Xd  S(   N(   Rw   Rz   R{   (   R   (    (    s   scripts/common/Lib/threading.pyt   runÚ  s    
c         C   s;   y |  i  ƒ  Wn& |  i o t d  j o d  S‚  n Xd  S(   N(   t   _Thread__bootstrap_innerR}   R#   R   (   R   (    (    s   scripts/common/Lib/threading.pyt   __bootstrapã  s    c         C   s   t  ƒ  |  _ d  S(   N(   t
   _get_identR~   (   R   (    (    s   scripts/common/Lib/threading.pyt
   _set_ident÷  s    c         C   s%  zã|  i  ƒ  |  i i ƒ  t i ƒ  |  t |  i <t |  =t i ƒ  |  i	 d |  ƒ t
 o! |  i	 d |  ƒ t i t
 ƒ n t o! |  i	 d |  ƒ t i t ƒ n z2y |  i ƒ  Wnt j
 o |  i	 d |  ƒ nü |  i	 d |  ƒ 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 } qVW|  i d | | f IJWd  ~ ~ ~ Xn X|  i	 d |  ƒ Wd  |  i ƒ  XWd  t i i ƒ  z& |  i  ƒ  y t t! ƒ  =Wn n XWd  QXXd  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   Rp   R‹   R7   t   _activeR~   RŒ   R<   R(   R-   R#   R   R+   R   R�   t
   SystemExitR$   R%   R"   t   _format_exct   _Thread__exc_infoRƒ   t   tb_framet   f_codet   co_filenamet	   tb_linenot   co_namet   tb_nextt   _Thread__exc_clearRA   RF   t   _Thread__stopR“   (   R   t   exc_typet	   exc_valuet   exc_tb(    (    s   scripts/common/Lib/threading.pyt   __bootstrap_innerú  sb    


 
 
c         C   s4   |  i  i ƒ  t |  _ |  i  i ƒ  |  i  i ƒ  d  S(   N(   R�   R7   RO   R€   Rd   R<   (   R   (    (    s   scripts/common/Lib/threading.pyt   __stopE  s    	c      	   C   sW   y& t  i i ƒ  z t t ƒ  =Wd QXWn* t j
 o d t i j o ‚  qS n Xd S(   sA   Remove current thread from the dict of currently running threads.Nt   dummy_threading(   R‹   RA   RF   R•   R“   t   KeyErrorR#   t   modules(   R   (    (    s   scripts/common/Lib/threading.pyt   __deleteK  s    c         C   sL  |  i  p t d ƒ ‚ n |  i i ƒ  p t d ƒ ‚ n |  t ƒ  j o t d ƒ ‚ n |  i p |  i d |  ƒ n |  i i ƒ  z² | d  j o3 x |  i p |  i i
 ƒ  q˜ W|  i d |  ƒ no t ƒ  | } x^ |  i pC | t ƒ  } | d j o |  i d |  ƒ Pn |  i i
 | ƒ qØ W|  i d |  ƒ 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‚   R;   R   Rr   R	   R€   R(   R�   R7   R   R]   RQ   R<   (   R   RV   t   deadlineRZ   (    (    s   scripts/common/Lib/threading.pyt   joinn  s2    

 
 
c         C   s   |  i  p
 t d ‚ |  i S(   Ns   Thread.__init__() not called(   R‚   Rv   Ry   (   R   (    (    s   scripts/common/Lib/threading.pyR"   �  s    c         C   s'   |  i  p
 t d ‚ t | ƒ |  _ d  S(   Ns   Thread.__init__() not called(   R‚   Rv   Rx   Ry   (   R   R"   (    (    s   scripts/common/Lib/threading.pyR"   ”  s    c         C   s   |  i  p
 t d ‚ |  i S(   Ns   Thread.__init__() not called(   R‚   Rv   R~   (   R   (    (    s   scripts/common/Lib/threading.pyt   ident™  s    c         C   s,   |  i  p
 t d ‚ |  i i ƒ  o |  i S(   Ns   Thread.__init__() not called(   R‚   Rv   R   Rr   R€   (   R   (    (    s   scripts/common/Lib/threading.pyt   isAlivež  s    c         C   s   |  i  p
 t d ‚ |  i S(   Ns   Thread.__init__() not called(   R‚   Rv   R}   (   R   (    (    s   scripts/common/Lib/threading.pyR†   ¤  s    c         C   sG   |  i  p t d ƒ ‚ n |  i i ƒ  o t d ƒ ‚ n | |  _ d  S(   Ns   Thread.__init__() not calleds)   cannot set daemon status of active thread(   R‚   R;   R   Rr   R}   (   R   t   daemonic(    (    s   scripts/common/Lib/threading.pyR†   ©  s
    
c         C   s   |  i  S(   N(   R†   (   R   (    (    s   scripts/common/Lib/threading.pyt   isDaemon±  s    c         C   s   | |  _  d  S(   N(   R†   (   R   R®   (    (    s   scripts/common/Lib/threading.pyt	   setDaemon´  s    c         C   s   |  i  S(   N(   R"   (   R   (    (    s   scripts/common/Lib/threading.pyt   getName·  s    c         C   s   | |  _  d  S(   N(   R"   (   R   R"   (    (    s   scripts/common/Lib/threading.pyt   setNameº  s    N(    (    R)   R*   RN   R‚   R#   t   exc_infoR˜   t	   exc_clearRŸ   R   R!   R|   R6   R�   R�   RŽ   R”   R‘   R    t   _Thread__deleteR«   t   propertyR"   t   setterR¬   R­   t   is_aliveR†   R¯   R°   R±   R²   (    (    (    s   scripts/common/Lib/threading.pyR   œ  s4   											K		#!				c          O   s   t  |  | Ž  S(   N(   t   _Timer(   R'   R/   (    (    s   scripts/common/Lib/threading.pyR   ¿  s    R¹   c           B   s/   e  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!   t   intervalt   functionR'   R/   R   t   finished(   R   Rº   R»   R'   R/   (    (    s   scripts/common/Lib/threading.pyR!   Ê  s    				c         C   s   |  i  i ƒ  d S(   s(   Stop the timer if it hasn't finished yetN(   R¼   Rp   (   R   (    (    s   scripts/common/Lib/threading.pyt   cancelÒ  s    c         C   sN   |  i  i |  i ƒ |  i  i ƒ  p |  i |  i |  i Ž  n |  i  i ƒ  d  S(   N(   R¼   R]   Rº   Rr   R»   R'   R/   Rp   (   R   (    (    s   scripts/common/Lib/threading.pyR�   Ö  s    (   R)   R*   Rk   R!   R½   R�   (    (    (    s   scripts/common/Lib/threading.pyR¹   Â  s   	t   _MainThreadc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sO   t  i |  d d ƒ|  i i ƒ  |  i ƒ  t i ƒ  |  t t ƒ  <t i	 ƒ  d  S(   NR"   t
   MainThread(
   R   R!   R   Rp   R”   R‹   R7   R•   R“   R<   (   R   (    (    s   scripts/common/Lib/threading.pyR!   á  s    

c         C   s   t  S(   N(   RN   (   R   (    (    s   scripts/common/Lib/threading.pyR|   é  s    c         C   sn   |  i  ƒ  t ƒ  } | o |  i d |  ƒ n x | o | i ƒ  t ƒ  } q1 W|  i d |  ƒ |  i ƒ  d  S(   Ns   %s: waiting for other threadss   %s: exiting(   R    t   _pickSomeNonDaemonThreadR(   R«   Rµ   (   R   R>   (    (    s   scripts/common/Lib/threading.pyt	   _exitfuncì  s    
	 
(   R)   R*   R!   R|   RÁ   (    (    (    s   scripts/common/Lib/threading.pyR¾   ß  s   		c          C   s5   x. t  ƒ  D]# }  |  i o |  i ƒ  o |  Sq
 Wd  S(   N(   R
   R†   R¸   R   (   R>   (    (    s   scripts/common/Lib/threading.pyRÀ   ù  s
    
 	t   _DummyThreadc           B   s&   e  Z d  „  Z d „  Z d d „ Z RS(   c         C   s[   t  i |  d t d ƒ ƒ|  ` |  i i ƒ  |  i ƒ  t i ƒ  |  t	 t
 ƒ  <t i ƒ  d  S(   NR"   s   Dummy-%d(   R   R!   Ru   R�   R   Rp   R”   R‹   R7   R•   R“   R<   (   R   (    (    s   scripts/common/Lib/threading.pyR!   
  s    

c         C   s   t  S(   N(   RO   (   R   (    (    s   scripts/common/Lib/threading.pyR|     s    c         C   s   t  p
 t d ‚ d  S(   Ns   cannot join a dummy thread(   RN   Rv   (   R   RV   (    (    s   scripts/common/Lib/threading.pyR«     s    N(   R)   R*   R!   R|   R   R«   (    (    (    s   scripts/common/Lib/threading.pyRÂ     s   		c           C   s-   y t  t ƒ  SWn t j
 o t ƒ  SXd  S(   N(   R•   R“   R§   RÂ   (    (    (    s   scripts/common/Lib/threading.pyR   !  s    c          C   s.   t  i ƒ  t t ƒ t t ƒ }  t  i ƒ  |  S(   N(   R‹   R7   RL   R•   RŒ   R<   (   R=   (    (    s   scripts/common/Lib/threading.pyR   *  s    

c          C   s.   t  i ƒ  t i ƒ  t i ƒ  }  t  i ƒ  |  S(   N(   R‹   R7   R•   t   valuesRŒ   R<   (   t   active(    (    s   scripts/common/Lib/threading.pyR
   2  s    

(   R   (   t   _local(   R   c          C   s¼   t  ƒ  a h  }  t ƒ  } t i i ƒ  zŒ xJ t i ƒ  D]< } | | j o  t ƒ  } | | _ | |  | <q7 t	 | _
 q7 Wt i ƒ  t i ƒ  t i |  ƒ t t ƒ d j p t ‚ Wd  QXd  S(   Ni   (   R0   R‹   R	   RA   RF   R•   t
   itervaluesR“   R~   RO   R€   RŒ   Rq   t   updateRL   Rv   (   t
   new_activet   currentt   threadR¬   (    (    s   scripts/common/Lib/threading.pyt   _after_forkI  s    		 		

c          C   s  d t  f d „  ƒ  Y}  d t f d „  ƒ  Y} d t f d „  ƒ  Y} d } d } d	 } |  | ƒ } g  } xA t | ƒ D]3 } | | | ƒ }	 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#   e  Z d  „  Z d „  Z d „  Z RS(   c         S   sV   t  i |  ƒ t ƒ  |  _ t |  i ƒ |  _ t |  i ƒ |  _ | |  _ t ƒ  |  _	 d  S(   N(
   R   R!   R   t   monR   R:   t   wct   limitR   t   queue(   R   RÏ   (    (    s   scripts/common/Lib/threading.pyR!   q  s    	c         S   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Í   R7   RL   RÐ   RÏ   R(   RÎ   R]   RP   R:   Rb   R<   (   R   t   item(    (    s   scripts/common/Lib/threading.pyt   puty  s     	c         S   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Í   R7   RÐ   R(   R:   R]   t   popleftRL   RÎ   Rb   R<   (   R   RÑ   (    (    s   scripts/common/Lib/threading.pyt   get„  s     
(   R)   R*   R!   RÒ   RÔ   (    (    (    s   scripts/common/Lib/threading.pyRÌ   o  s   		t   ProducerThreadc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s)   t  i |  d d ƒ| |  _ | |  _ d  S(   NR"   t   Producer(   R   R!   RÐ   t   quota(   R   RÐ   R×   (    (    s   scripts/common/Lib/threading.pyR!   ‘  s    	c         S   sj   d d k  l  } d } xM | |  i j  o< | d } |  i i d |  i | f ƒ t | ƒ  d ƒ q Wd  S(   Niÿÿÿÿ(   t   randomi    i   s   %s.%dgñhãˆµøä>(   RØ   R×   RÐ   RÒ   R"   RS   (   R   RØ   t   counter(    (    s   scripts/common/Lib/threading.pyR�   –  s     
(   R)   R*   R!   R�   (    (    (    s   scripts/common/Lib/threading.pyRÕ   �  s   	t   ConsumerThreadc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s)   t  i |  d d ƒ| |  _ | |  _ d  S(   NR"   t   Consumer(   R   R!   RÐ   R=   (   R   RÐ   R=   (    (    s   scripts/common/Lib/threading.pyR!   ¡  s    	c         S   s@   x9 |  i  d j o( |  i i ƒ  } | GH|  i  d |  _  q Wd  S(   Ni    i   (   R=   RÐ   RÔ   (   R   RÑ   (    (    s   scripts/common/Lib/threading.pyR�   ¦  s
     (   R)   R*   R!   R�   (    (    (    s   scripts/common/Lib/threading.pyRÚ   Ÿ  s   	i   i   i   s   Producer-%di   g�íµ ÷Æ°>(   R   R   t   rangeR"   RP   R�   RS   R«   (   RÌ   RÕ   RÚ   t   NPt   QLt   NIt   Qt   Pt   iR>   t   C(    (    s   scripts/common/Lib/threading.pyt   _testm  s.       

 t   __main__(J   Rk   t   sysR#   RÊ   t   ImportErrorR¨   R)   t   warningst	   functoolsR    R   RQ   R   RS   t	   tracebackR   R—   t   collectionsR   t   __all__t   start_new_threadR�   t   allocate_lockR0   t	   get_identR“   t   errort   ThreadErrort   filterwarningst   DeprecationWarningRN   R   t   objectR   R   R+   R-   R   R   R   R   R.   R   RG   R   Re   R   Ri   R   Rl   Rs   Ru   R‹   R•   RŒ   R   R   R¹   R¾   RÀ   RÂ   R   R	   R   R   R
   R   RÁ   t	   _shutdownRÅ   R   t   _threading_localRË   Rä   (    (    (    s   scripts/common/Lib/threading.pyt   <module>   s„   
								K	u	-		&	ÿ $						$	R