
!Xc           @   s  d  Z  d d l Z y d d l Z Wn e k
 rB e j e =  n Xd d l Z d d l m Z	 m
 Z d d l m Z d d d d d	 d
 d d d d d d d d d d d g Z e j Z e j Z e j Z e j Z [ e j 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,   Z, d- e f d.     YZ- d/ a. d0 d1  Z/ e   a0 i  Z1 i  Z2 d e f d2     YZ3 d3   Z4 d4 e3 f d5     YZ5 d6 e3 f d7     YZ6 d8   Z7 d9 e3 f d:     YZ8 d;   Z9 e9 Z: d<   Z; e; Z< d=   Z= d>   Z> d d? l m? Z? e6   j@ ZA y d d@ l mB ZC Wn! e k
 rd dA lD mC ZC n XdB   ZE dC   ZF e dD k reF   n  d S(E   s;   Thread module emulating a subset of Java's threading model.iN(   t   timet   sleep(   t
   format_exct   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  k r t } n  | |  _ d  S(   N(   t   Nonet   _VERBOSEt   _Verbose__verbose(   t   selft   verbose(    (    s   /usr/lib/python2.7/threading.pyt   __init__9   s    	c         G   sr   |  j  rn | | } t   } y t | j } Wn t k
 rJ d | } n Xd | | f } t j j |  n  d  S(   Ns   <OS thread %d>s   %s: %s
(   R   t
   _get_identt   _activet   namet   KeyErrort   _syst   stderrt   write(   R   t   formatt   argst   identR"   (    (    s   /usr/lib/python2.7/threading.pyt   _note>   s    	
	N(   t   __name__t
   __module__R   R   R*   (    (    (    s   /usr/lib/python2.7/threading.pyR   7   s   c         C   s
   |  a  d  S(   N(   t   _profile_hook(   t   func(    (    s   /usr/lib/python2.7/threading.pyR   X   s    c         C   s
   |  a  d  S(   N(   t   _trace_hook(   R.   (    (    s   /usr/lib/python2.7/threading.pyR   \   s    c          O   s   t  |  |   S(   N(   t   _RLock(   R(   t   kwargs(    (    s   /usr/lib/python2.7/threading.pyR   d   s    R0   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  j |  |  t   |  _ d  |  _ d |  _ d  S(   Ni    (   R   R   t   _allocate_lockt   _RLock__blockR   t   _RLock__ownert   _RLock__count(   R   R   (    (    s   /usr/lib/python2.7/threading.pyR   i   s    	c         C   sH   |  j  } y t | j } Wn t k
 r- n Xd |  j j | |  j f S(   Ns   <%s owner=%r count=%d>(   R4   R!   R"   R#   t	   __class__R+   R5   (   R   t   owner(    (    s   /usr/lib/python2.7/threading.pyt   __repr__o   s    	i   c         C   s   t    } |  j | k r? |  j d |  _ |  j d |  |  d S|  j j |  } | r | |  _ d |  _ |  j d |  |  n |  j d |  |  | S(   Ni   s!   %s.acquire(%s): recursive successs   %s.acquire(%s): initial successs   %s.acquire(%s): failure(   R    R4   R5   R*   R3   t   acquire(   R   t   blockingt   met   rc(    (    s   /usr/lib/python2.7/threading.pyR9   x   s    			c         C   sx   |  j  t   k r! t d   n  |  j d |  _ } | sd d  |  _  |  j j   |  j d |   n |  j d |   d  S(   Ns   cannot release un-acquired locki   s   %s.release(): final releases   %s.release(): non-final release(   R4   R    t   RuntimeErrorR5   R   R3   t   releaseR*   (   R   t   count(    (    s   /usr/lib/python2.7/threading.pyR>      s    	c         C   s   |  j    d  S(   N(   R>   (   R   t   tt   vt   tb(    (    s   /usr/lib/python2.7/threading.pyt   __exit__   s    c         C   s?   | \ } } |  j  j   | |  _ | |  _ |  j d |   d  S(   Ns   %s._acquire_restore()(   R3   R9   R5   R4   R*   (   R   t   count_ownerR?   R7   (    (    s   /usr/lib/python2.7/threading.pyt   _acquire_restore   s
    		c         C   sK   |  j  d |   |  j } d |  _ |  j } d  |  _ |  j j   | | f S(   Ns   %s._release_save()i    (   R*   R5   R4   R   R3   R>   (   R   R?   R7   (    (    s   /usr/lib/python2.7/threading.pyt   _release_save   s    				c         C   s   |  j  t   k S(   N(   R4   R    (   R   (    (    s   /usr/lib/python2.7/threading.pyt	   _is_owned   s    N(   R+   R,   R   R   R8   R9   t	   __enter__R>   RC   RE   RF   RG   (    (    (    s   /usr/lib/python2.7/threading.pyR0   g   s   						
c          O   s   t  |  |   S(   N(   t
   _Condition(   R(   R1   (    (    s   /usr/lib/python2.7/threading.pyR      s    RI   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  j |  |  | d  k r( t   } n  | |  _ | j |  _ | j |  _ y | j |  _ Wn t k
 rl n Xy | j	 |  _	 Wn t k
 r n Xy | j
 |  _
 Wn t k
 r n Xg  |  _ d  S(   N(   R   R   R   R   t   _Condition__lockR9   R>   RF   t   AttributeErrorRE   RG   t   _Condition__waiters(   R   t   lockR   (    (    s   /usr/lib/python2.7/threading.pyR      s&    	c         C   s   |  j  j   S(   N(   RJ   RH   (   R   (    (    s   /usr/lib/python2.7/threading.pyRH      s    c         G   s   |  j  j |   S(   N(   RJ   RC   (   R   R(   (    (    s   /usr/lib/python2.7/threading.pyRC      s    c         C   s   d |  j  t |  j  f S(   Ns   <Condition(%s, %d)>(   RJ   t   lenRL   (   R   (    (    s   /usr/lib/python2.7/threading.pyR8      s    c         C   s   |  j  j   d  S(   N(   RJ   R>   (   R   (    (    s   /usr/lib/python2.7/threading.pyRF      s    c         C   s   |  j  j   d  S(   N(   RJ   R9   (   R   t   x(    (    s   /usr/lib/python2.7/threading.pyRE      s    c         C   s+   |  j  j d  r# |  j  j   t St Sd  S(   Ni    (   RJ   R9   R>   t   Falset   True(   R   (    (    s   /usr/lib/python2.7/threading.pyRG      s    c         C   sY  |  j    s t d   n  t   } | j   |  j j |  |  j   } z | d  k rv | j   |  j d |   n t	   | } d } x` t
 r | j d  } | r Pn  | t	   } | d k r Pn  t | d | d  } t |  q W| s0|  j d |  |  y |  j j |  WqCt k
 r,qCXn |  j d |  |  Wd  |  j |  Xd  S(	   Ns   cannot wait on un-acquired locks   %s.wait(): got itgMb@?i    i   g?s   %s.wait(%s): timed outs   %s.wait(%s): got it(   RG   R=   R2   R9   RL   t   appendRF   R   R*   t   _timeRQ   t   mint   _sleept   removet
   ValueErrorRE   (   R   t   timeoutt   waitert   saved_statet   endtimet   delayt   gotitt	   remaining(    (    s   /usr/lib/python2.7/threading.pyt   wait   s:    	

	i   c         C   s   |  j    s t d   n  |  j } | |  } | sH |  j d |   d  S|  j d |  | | d k ri d pl d  x= | D]5 } | j   y | j |  Wqw t k
 r qw Xqw Wd  S(   Ns!   cannot notify on un-acquired locks   %s.notify(): no waiterss"   %s.notify(): notifying %d waiter%si   t   st    (   RG   R=   RL   R*   R>   RV   RW   (   R   t   nRL   t   waitersRY   (    (    s   /usr/lib/python2.7/threading.pyt   notify  s    	

c         C   s   |  j  t |  j   d  S(   N(   Rd   RN   RL   (   R   (    (    s   /usr/lib/python2.7/threading.pyt	   notifyAll&  s    N(   R+   R,   R   R   RH   RC   R8   RF   RE   RG   R_   Rd   Re   t
   notify_all(    (    (    s   /usr/lib/python2.7/threading.pyRI      s   							*	c          O   s   t  |  |   S(   N(   t
   _Semaphore(   R(   R1   (    (    s   /usr/lib/python2.7/threading.pyR   ,  s    Rg   c           B   s;   e  Z d  d d  Z d  d  Z e Z d   Z d   Z RS(   i   c         C   sJ   | d k  r t  d   n  t j |  |  t t    |  _ | |  _ d  S(   Ni    s$   semaphore initial value must be >= 0(   RW   R   R   R   R
   t   _Semaphore__condt   _Semaphore__value(   R   t   valueR   (    (    s   /usr/lib/python2.7/threading.pyR   3  s
    c         C   s   t  } |  j j   xo |  j d k rX | s/ Pn  |  j d |  | |  j  |  j j   q W|  j d |  _ |  j d |  |  j  t } |  j j   | S(   Ni    s)   %s.acquire(%s): blocked waiting, value=%si   s   %s.acquire: success, value=%s(   RP   Rh   R9   Ri   R*   R_   RQ   R>   (   R   R:   R<   (    (    s   /usr/lib/python2.7/threading.pyR9   :  s    		c         C   sQ   |  j  j   |  j d |  _ |  j d |  |  j  |  j  j   |  j  j   d  S(   Ni   s   %s.release: success, value=%s(   Rh   R9   Ri   R*   Rd   R>   (   R   (    (    s   /usr/lib/python2.7/threading.pyR>   O  s    	c         C   s   |  j    d  S(   N(   R>   (   R   R@   RA   RB   (    (    s   /usr/lib/python2.7/threading.pyRC   X  s    N(   R+   R,   R   R   R9   RH   R>   RC   (    (    (    s   /usr/lib/python2.7/threading.pyRg   /  s
   		c          O   s   t  |  |   S(   N(   t   _BoundedSemaphore(   R(   R1   (    (    s   /usr/lib/python2.7/threading.pyR   \  s    Rk   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  j |  | |  | |  _ d  S(   N(   Rg   R   t   _initial_value(   R   Rj   R   (    (    s   /usr/lib/python2.7/threading.pyR   a  s    c         C   s+   |  j  |  j k r t d  n  t j |   S(   Ns!   Semaphore released too many times(   Ri   Rl   RW   Rg   R>   (   R   (    (    s   /usr/lib/python2.7/threading.pyR>   e  s    N(   R+   R,   t   __doc__R   R   R>   (    (    (    s   /usr/lib/python2.7/threading.pyRk   _  s   c          O   s   t  |  |   S(   N(   t   _Event(   R(   R1   (    (    s   /usr/lib/python2.7/threading.pyR	   k  s    Rn   c           B   sJ   e  Z d d   Z d   Z d   Z e Z d   Z d   Z d d  Z	 RS(   c         C   s/   t  j |  |  t t    |  _ t |  _ d  S(   N(   R   R   R   R
   t   _Event__condRP   t   _Event__flag(   R   R   (    (    s   /usr/lib/python2.7/threading.pyR   r  s    c         C   s   |  j  j   d  S(   N(   Ro   R   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   _reset_internal_locksw  s    c         C   s   |  j  S(   N(   Rp   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   isSet{  s    c         C   s<   |  j  j   z t |  _ |  j  j   Wd  |  j  j   Xd  S(   N(   Ro   R9   RQ   Rp   Rf   R>   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   set  s
    	c         C   s/   |  j  j   z t |  _ Wd  |  j  j   Xd  S(   N(   Ro   R9   RP   Rp   R>   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   clear  s    c         C   sI   |  j  j   z' |  j s, |  j  j |  n  |  j SWd  |  j  j   Xd  S(   N(   Ro   R9   Rp   R_   R>   (   R   RX   (    (    s   /usr/lib/python2.7/threading.pyR_     s    	N(
   R+   R,   R   R   Rq   Rr   t   is_setRs   Rt   R_   (    (    (    s   /usr/lib/python2.7/threading.pyRn   n  s   				i    s	   Thread-%dc         C   s   t  d a  |  t  S(   Ni   (   t   _counter(   t   template(    (    s   /usr/lib/python2.7/threading.pyt   _newname  s    
c           B   s4  e  Z e Z e j Z e j Z d d d d d d d   Z
 d   Z e 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 j d    Z e d    Z d   Z e Z e d    Z e j d    Z d   Z d   Z d   Z  d   Z! RS(   c         C   s   | d  k s t d   t j |  |  | d  k r= i  } n  | |  _ t | pU t    |  _ | |  _ | |  _	 |  j
   |  _ d  |  _ t   |  _ t |  _ t t    |  _ t |  _ t j |  _ d  S(   Ns#   group argument must be None for now(   R   t   AssertionErrorR   R   t   _Thread__targett   strRx   t   _Thread__namet   _Thread__argst   _Thread__kwargst   _set_daemont   _Thread__daemonict   _Thread__identR	   t   _Thread__startedRP   t   _Thread__stoppedR   R
   t   _Thread__blockRQ   t   _Thread__initializedR$   R%   t   _Thread__stderr(   R   t   groupt   targetR"   R(   R1   R   (    (    s   /usr/lib/python2.7/threading.pyR     s    							c         C   s0   t  |  d  r |  j j   n  |  j j   d  S(   NR   (   t   hasattrR   R   R   Rq   (   R   (    (    s   /usr/lib/python2.7/threading.pyRq     s    c         C   s   |  j  S(   N(   R   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   _block  s    c         C   s
   t    j S(   N(   R   t   daemon(   R   (    (    s   /usr/lib/python2.7/threading.pyR     s    c         C   s   |  j  s t d   d } |  j j   r3 d } n  |  j rE d } n  |  j r[ | d 7} n  |  j d  k	 r~ | d |  j 7} n  d |  j j	 |  j
 | f S(   Ns    Thread.__init__() was not calledt   initialt   startedt   stoppeds    daemons    %ss   <%s(%s, %s)>(   R   Ry   R   Ru   R   R   R   R   R6   R+   R|   (   R   t   status(    (    s   /usr/lib/python2.7/threading.pyR8     s    				c         C   s   |  j  s t d   n  |  j j   r6 t d   n  |  j d |   t  |  t |  <Wd  QXy t |  j d  Wn( t	 k
 r t  t |  =Wd  QX  n X|  j j
   d  S(   Ns   thread.__init__() not calleds    threads can only be started onces   %s.start(): starting thread(    (   R   R=   R   Ru   R*   t   _active_limbo_lockt   _limbot   _start_new_threadt   _Thread__bootstrapt	   ExceptionR_   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   start  s    	c         C   s@   z& |  j  r% |  j  |  j |  j   n  Wd  |  `  |  ` |  ` Xd  S(   N(   Rz   R}   R~   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   run  s    	c         C   s8   y |  j    Wn# |  j r- t d  k r- d  S  n Xd  S(   N(   t   _Thread__bootstrap_innerR   R$   R   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   __bootstrap  s    c         C   s   t    |  _ d  S(   N(   R    R   (   R   (    (    s   /usr/lib/python2.7/threading.pyt
   _set_ident  s    c      
   C   s	  z|  j    |  j j   t  |  t |  j <t |  =Wd  QX|  j d |   t rq |  j d |   t	 j
 t  n  t r |  j d |   t	 j t  n  z,y |  j   Wnt k
 r |  j d |   n |  j d |   t	 rt	 j j d |  j t   f  q|  j   \ } } } z |  j d |  j d IJ|  j d	 IJxB | r|  j d
 | j j j | j | j j j f IJ| j } qGW|  j d | | f IJWd  ~ ~ ~ Xn X|  j d |   Wd  |  j   XWd  t ' |  j   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   Rs   R   R!   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_cleart   _Thread__stopR    (   R   t   exc_typet	   exc_valuet   exc_tb(    (    s   /usr/lib/python2.7/threading.pyt   __bootstrap_inner  s^    
 
	
c         C   sG   t  |  d  s d  S|  j j   t |  _ |  j j   |  j j   d  S(   NR   (   R   R   R9   RQ   R   Rf   R>   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   __stop_  s    	c         C   sH   y t   t t   =Wd QXWn& t k
 rC d t j k rD   qD n Xd S(   sA   Remove current thread from the dict of currently running threads.Nt   dummy_threading(   R   R!   R    R#   R$   t   modules(   R   (    (    s   /usr/lib/python2.7/threading.pyt   __deletei  s    c         C   s<  |  j  s t d   n  |  j j   s6 t d   n  |  t   k rT t d   n  |  j sp |  j d |   n  |  j j   z | d  k r x |  j s |  j j
   q W|  j d |   nj t   | } xZ |  j s| t   } | d k r|  j d |   Pn  |  j j
 |  q W|  j d |   Wd  |  j j   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   Ru   R   R   R*   R   R9   R   R_   RS   R>   (   R   RX   t   deadlineR\   (    (    s   /usr/lib/python2.7/threading.pyt   join  s.    		c         C   s   |  j  s t d   |  j S(   Ns   Thread.__init__() not called(   R   Ry   R|   (   R   (    (    s   /usr/lib/python2.7/threading.pyR"     s    c         C   s(   |  j  s t d   t |  |  _ d  S(   Ns   Thread.__init__() not called(   R   Ry   R{   R|   (   R   R"   (    (    s   /usr/lib/python2.7/threading.pyR"     s    c         C   s   |  j  s t d   |  j S(   Ns   Thread.__init__() not called(   R   Ry   R   (   R   (    (    s   /usr/lib/python2.7/threading.pyR)     s    c         C   s,   |  j  s t d   |  j j   o+ |  j S(   Ns   Thread.__init__() not called(   R   Ry   R   Ru   R   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   isAlive  s    c         C   s   |  j  s t d   |  j S(   Ns   Thread.__init__() not called(   R   Ry   R   (   R   (    (    s   /usr/lib/python2.7/threading.pyR     s    c         C   sC   |  j  s t d   n  |  j j   r6 t d   n  | |  _ d  S(   Ns   Thread.__init__() not calleds)   cannot set daemon status of active thread(   R   R=   R   Ru   R   (   R   t   daemonic(    (    s   /usr/lib/python2.7/threading.pyR     s
    	c         C   s   |  j  S(   N(   R   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   isDaemon  s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s   /usr/lib/python2.7/threading.pyt	   setDaemon  s    c         C   s   |  j  S(   N(   R"   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   getName  s    c         C   s   | |  _  d  S(   N(   R"   (   R   R"   (    (    s   /usr/lib/python2.7/threading.pyt   setName  s    N(    ("   R+   R,   RP   R   R$   t   exc_infoR   t	   exc_clearR   R   R   Rq   t   propertyR   R   R8   R   R   R   R   R   R   t   _Thread__deleteR   R"   t   setterR)   R   t   is_aliveR   R   R   R   R   (    (    (    s   /usr/lib/python2.7/threading.pyR     s8   												J	
	#!				c          O   s   t  |  |   S(   N(   t   _Timer(   R(   R1   (    (    s   /usr/lib/python2.7/threading.pyR     s    R   c           B   s/   e  Z d  Z g  i  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  j |   | |  _ | |  _ | |  _ | |  _ t   |  _ d  S(   N(   R   R   t   intervalt   functionR(   R1   R	   t   finished(   R   R   R   R(   R1   (    (    s   /usr/lib/python2.7/threading.pyR     s    				c         C   s   |  j  j   d S(   s(   Stop the timer if it hasn't finished yetN(   R   Rs   (   R   (    (    s   /usr/lib/python2.7/threading.pyt   cancel  s    c         C   sL   |  j  j |  j  |  j  j   s; |  j |  j |  j   n  |  j  j   d  S(   N(   R   R_   R   Ru   R   R(   R1   Rs   (   R   (    (    s   /usr/lib/python2.7/threading.pyR     s    (   R+   R,   Rm   R   R   R   (    (    (    s   /usr/lib/python2.7/threading.pyR     s   	t   _MainThreadc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   sH   t  j |  d d |  j j   |  j   t  |  t t   <Wd  QXd  S(   NR"   t
   MainThread(   R   R   R   Rs   R   R   R!   R    (   R   (    (    s   /usr/lib/python2.7/threading.pyR     s
    
c         C   s   t  S(   N(   RP   (   R   (    (    s   /usr/lib/python2.7/threading.pyR     s    c         C   sj   |  j    t   } | r, |  j d |   n  x | rK | j   t   } q/ W|  j d |   |  j   d  S(   Ns   %s: waiting for other threadss   %s: exiting(   R   t   _pickSomeNonDaemonThreadR*   R   R   (   R   R@   (    (    s   /usr/lib/python2.7/threading.pyt	   _exitfunc	  s    
		
(   R+   R,   R   R   R   (    (    (    s   /usr/lib/python2.7/threading.pyR     s   		c          C   s2   x+ t    D]  }  |  j r
 |  j   r
 |  Sq
 Wd  S(   N(   R   R   R   R   (   R@   (    (    s   /usr/lib/python2.7/threading.pyR     s    t   _DummyThreadc           B   s&   e  Z d    Z d   Z d d  Z RS(   c         C   sT   t  j |  d t d  |  ` |  j j   |  j   t  |  t t	   <Wd  QXd  S(   NR"   s   Dummy-%d(
   R   R   Rx   R   R   Rs   R   R   R!   R    (   R   (    (    s   /usr/lib/python2.7/threading.pyR   '  s    
c         C   s   t  S(   N(   RQ   (   R   (    (    s   /usr/lib/python2.7/threading.pyR   4  s    c         C   s   t  s t d   d  S(   Ns   cannot join a dummy thread(   RP   Ry   (   R   RX   (    (    s   /usr/lib/python2.7/threading.pyR   7  s    N(   R+   R,   R   R   R   R   (    (    (    s   /usr/lib/python2.7/threading.pyR   %  s   		c           C   s+   y t  t   SWn t k
 r& t   SXd  S(   N(   R!   R    R#   R   (    (    (    s   /usr/lib/python2.7/threading.pyR   =  s    c           C   s%   t   t t  t t  SWd  QXd  S(   N(   R   RN   R!   R   (    (    (    s   /usr/lib/python2.7/threading.pyR   F  s    c           C   s   t  j   t j   S(   N(   R!   t   valuesR   (    (    (    s   /usr/lib/python2.7/threading.pyt
   _enumerateL  s    c           C   s%   t   t j   t j   SWd  QXd  S(   N(   R   R!   R   R   (    (    (    s   /usr/lib/python2.7/threading.pyR   P  s    (   R   (   t   _local(   R   c          C   s   t    a i  }  t   } t  xe t j   D]W } t | d  rN | j   n  | | k ry t   } | | _ | |  | <q, | j	   q, Wt
 j   t j   t j |   t t  d k s t  Wd  QXd  S(   NRq   i   (   R2   R   R   R!   t
   itervaluesR   Rq   R    R   R   R   Rt   t   updateRN   Ry   (   t
   new_activet   currentt   threadR)   (    (    s   /usr/lib/python2.7/threading.pyt   _after_forke  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 |	 _ | j |	  qs W| | | |  }
 x" | D] }	 |	 j   t d  q W|
 j   x | D] }	 |	 j   q W|
 j   d  S(   Nt   BoundedQueuec           B   s#   e  Z d    Z d   Z d   Z RS(   c         S   sV   t  j |   t   |  _ t |  j  |  _ t |  j  |  _ | |  _ t   |  _	 d  S(   N(
   R   R   R   t   monR   R<   t   wct   limitt   dequet   queue(   R   R   (    (    s   /usr/lib/python2.7/threading.pyR     s    	c         S   s   |  j  j   x9 t |  j  |  j k rH |  j d |  |  j j   q W|  j j |  |  j d | t |  j   |  j	 j
   |  j  j   d  S(   Ns   put(%s): queue fulls    put(%s): appended, length now %d(   R   R9   RN   R   R   R*   R   R_   RR   R<   Rd   R>   (   R   t   item(    (    s   /usr/lib/python2.7/threading.pyt   put  s    	c         S   s   |  j  j   x' |  j s6 |  j d  |  j j   q W|  j j   } |  j d | t |  j   |  j j	   |  j  j
   | S(   Ns   get(): queue emptys   get(): got %s, %d left(   R   R9   R   R*   R<   R_   t   popleftRN   R   Rd   R>   (   R   R   (    (    s   /usr/lib/python2.7/threading.pyt   get  s    (   R+   R,   R   R   R   (    (    (    s   /usr/lib/python2.7/threading.pyR     s   		t   ProducerThreadc           B   s   e  Z d    Z d   Z RS(   c         S   s)   t  j |  d d | |  _ | |  _ d  S(   NR"   t   Producer(   R   R   R   t   quota(   R   R   R   (    (    s   /usr/lib/python2.7/threading.pyR     s    	c         S   sh   d d l  m  } d } xK | |  j k  rc | d } |  j j d |  j | f  t |   d  q Wd  S(   Ni(   t   randomi    i   s   %s.%dgh㈵>(   R   R   R   R   R"   RU   (   R   R   t   counter(    (    s   /usr/lib/python2.7/threading.pyR     s    
(   R+   R,   R   R   (    (    (    s   /usr/lib/python2.7/threading.pyR     s   	t   ConsumerThreadc           B   s   e  Z d    Z d   Z RS(   c         S   s)   t  j |  d d | |  _ | |  _ d  S(   NR"   t   Consumer(   R   R   R   R?   (   R   R   R?   (    (    s   /usr/lib/python2.7/threading.pyR     s    	c         S   s>   x7 |  j  d k r9 |  j j   } | GH|  j  d |  _  q Wd  S(   Ni    i   (   R?   R   R   (   R   R   (    (    s   /usr/lib/python2.7/threading.pyR     s    (   R+   R,   R   R   (    (    (    s   /usr/lib/python2.7/threading.pyR     s   	i   i   i   s   Producer-%di   gư>(   R   R   t   rangeR"   RR   R   RU   R   (   R   R   R   t   NPt   QLt   NIt   Qt   Pt   iR@   t   C(    (    s   /usr/lib/python2.7/threading.pyt   _test  s(     

t   __main__(G   Rm   t   sysR$   R   t   ImportErrorR   R+   t   warningsR    RS   R   RU   t	   tracebackR   R   t   __all__t   start_new_threadR   t   allocate_lockR2   t	   get_identR    t   errort   ThreadErrort   filterwarningst   DeprecationWarningRP   R   t   objectR   R   R-   R/   R   R   R
   R   R0   R   RI   R   Rg   R   Rk   R	   Rn   Rv   Rx   R   R!   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t	   _shutdownR   R   t   _threading_localR   R   (    (    (    s   /usr/lib/python2.7/threading.pyt   <module>   s   
								M	u	-		+	 7							%	R