�`^c@s dZddlZyddlZWnek
rBeje=�nXddlZddlm Z
ddlmZm
ZddlmZdddd d
ddd
dddddddddgZejZejZejZejZ[ejddedddd�eZdefd��YZ e!a"e!a#d�Z$d �Z%eZ&d!�Z'd"e fd#��YZ(d$�Z)d%e fd&��YZ*d'�Z+d(e fd)��YZ,d*�Z-d+e,fd,��YZ.d-�Z/d.e fd/��YZ0d0a1d1d2�Z2e�a3iZ4iZ5de fd3��YZ6d4�Z7d5e6fd6��YZ8d7e6fd8��YZ9d9�Z:d:e6fd;��YZ;d<�Z<e<Z=d=�Z>e>Z?d>�Z@d?�ZAdd@lmBZBe9�jCZDyddAlmEZFWn!ek
r�ddBlGmFZFnXdC�ZHdD�ZIedEkreI�ndS(Fs;Thread module emulating a subset of Java's threading model.i�N(tdeque(ttimetsleep(t
format_exctactiveCounttactive_countt Conditiont
currentThreadtcurrent_threadt enumeratetEventtLocktRLockt SemaphoretBoundedSemaphoretThreadtTimert
setprofiletsettracetlocalt
stack_sizetignoretcategorytmodulet threadingtmessages
sys.exc_cleart_VerbosecBseZdd�Zd�ZRS(cCsdS(N((tselftverbose((s/sys/lib/python2.7/threading.pyt__init__OscGsdS(N((Rtargs((s/sys/lib/python2.7/threading.pyt_noteQsN(t__name__t
__module__tNoneRR(((s/sys/lib/python2.7/threading.pyRNscCs
|adS(s�Set a profile function for all threads started from the threading module.
The func will be passed to sys.setprofile() for each thread, before its
run() method is called.
N(t
_profile_hook(tfunc((s/sys/lib/python2.7/threading.pyRYscCs
|adS(s�Set a trace function for all threads started from the threading module.
The func will be passed to sys.settrace() for each thread, before its run()
method is called.
N(t_trace_hook(R$((s/sys/lib/python2.7/threading.pyRcscOs
t||�S(s2Factory function that returns a new reentrant lock.
A reentrant lock must be released by the thread that acquired it. Once a
thread has acquired a reentrant lock, the same thread may acquire it again
without blocking; the thread must release it once for each time it has
acquired it.
(t_RLock(Rtkwargs((s/sys/lib/python2.7/threading.pyRqs R&cBsbeZdZd
d�Zd�Zdd�ZeZd�Zd�Z d�Z
d�Zd �ZRS(sA reentrant lock must be released by the thread that acquired it. Once a
thread has acquired a reentrant lock, the same thread may acquire it
again without blocking; the thread must release it once for each time it
has acquired it.
cCs2tj||�t�|_d|_d|_dS(Ni(RRt_allocate_lockt
_RLock__blockR"t
_RLock__ownert
_RLock__count(RR((s/sys/lib/python2.7/threading.pyR�s cCsH|j}yt|j}Wntk
r-nXd|jj||jfS(Ns<%s owner=%r count=%d>(R*t_activetnametKeyErrort __class__R R+(Rtowner((s/sys/lib/python2.7/threading.pyt__repr__�s
icCs]t�}|j|kr,|jd|_dS|jj|�}|rY||_d|_n|S(s�Acquire a lock, blocking or non-blocking.
When invoked without arguments: if this thread already owns the lock,
increment the recursion level by one, and return immediately. Otherwise,
if another thread owns the lock, block until the lock is unlocked. Once
the lock is unlocked (not owned by any thread), then grab ownership, set
the recursion level to one, and return. If more than one thread is
blocked waiting until the lock is unlocked, only one at a time will be
able to grab ownership of the lock. There is no return value in this
case.
When invoked with the blocking argument set to true, do the same thing
as when called without arguments, and return true.
When invoked with the blocking argument set to false, do not block. If a
call without an argument would block, return false immediately;
otherwise, do the same thing as when called without arguments, and
return true.
i(t
_get_identR*R+R)tacquire(Rtblockingtmetrc((s/sys/lib/python2.7/threading.pyR3�s cCsX|jt�kr!td��n|jd|_}|sTd|_|jj�ndS(smRelease a lock, decrementing the recursion level.
If after the decrement it is zero, reset the lock to unlocked (not owned
by any thread), and if any other threads are blocked waiting for the
lock to become unlocked, allow exactly one of them to proceed. If after
the decrement the recursion level is still nonzero, the lock remains
locked and owned by the calling thread.
Only call this method when the calling thread owns the lock. A
RuntimeError is raised if this method is called when the lock is
unlocked.
There is no return value.
scannot release un-acquired lockiN(R*R2tRuntimeErrorR+R"R)trelease(Rtcount((s/sys/lib/python2.7/threading.pyR8�s
cCs|j�dS(N(R8(Rtttvttb((s/sys/lib/python2.7/threading.pyt__exit__�scCs/|\}}|jj�||_||_dS(N(R)R3R+R*(Rtcount_ownerR9R0((s/sys/lib/python2.7/threading.pyt_acquire_restore�s
cCs;|j}d|_|j}d|_|jj�||fS(Ni(R+R*R"R)R8(RR9R0((s/sys/lib/python2.7/threading.pyt
_release_save�s
cCs|jt�kS(N(R*R2(R((s/sys/lib/python2.7/threading.pyt _is_owned�sN(
R R!t__doc__R"RR1R3t __enter__R8R=R?R@RA(((s/sys/lib/python2.7/threading.pyR&|s &
cOs
t||�S(s}Factory function that returns a new condition variable object.
A condition variable allows one or more threads to wait until they are
notified by another thread.
If the lock argument is given and not None, it must be a Lock or RLock
object, and it is used as the underlying lock. Otherwise, a new RLock object
is created and used as the underlying lock.
(t
_Condition(RR'((s/sys/lib/python2.7/threading.pyR�sRDcBszeZdZddd�Zd�Zd�Zd�Zd�Zd�Z d�Z
dd�Zd d
�Zd�Z
e
ZRS(
slCondition variables allow one or more threads to wait until they are
notified by another thread.
cCs�tj||�|dkr(t�}n||_|j|_|j|_y|j|_Wntk
rlnXy|j |_ Wntk
r�nXy|j
|_
Wntk
r�nXg|_dS(N(RRR"Rt_Condition__lockR3R8R@tAttributeErrorR?RAt_Condition__waiters(RtlockR((s/sys/lib/python2.7/threading.pyRs&
cCs
|jj�S(N(RERC(R((s/sys/lib/python2.7/threading.pyRCscGs|jj|�S(N(RER=(RR((s/sys/lib/python2.7/threading.pyR=scCsd|jt|j�fS(Ns<Condition(%s, %d)>(REtlenRG(R((s/sys/lib/python2.7/threading.pyR1"scCs|jj�dS(N(RER8(R((s/sys/lib/python2.7/threading.pyR@%scCs|jj�dS(N(RER3(Rtx((s/sys/lib/python2.7/threading.pyR?(scCs+|jjd�r#|jj�tStSdS(Ni(RER3R8tFalsetTrue(R((s/sys/lib/python2.7/threading.pyRA+s
cCs#|j�std��nt�}|j�|jj|�|j�}z�|dkrf|j�n�t�|}d}x`t r�|jd�}|r�Pn|t�}|dkr�Pnt
|d|d�}t|�q|W|s
y|jj|�Wq
t
k
r q
XnWd|j|�XdS(sjWait until notified or until a timeout occurs.
If the calling thread has not acquired the lock when this method is
called, a RuntimeError is raised.
This method releases the underlying lock, and then blocks until it is
awakened by a notify() or notifyAll() call for the same condition
variable in another thread, or until the optional timeout occurs. Once
awakened or timed out, it re-acquires the lock and returns.
When the timeout argument is present and not None, it should be a
floating point number specifying a timeout for the operation in seconds
(or fractions thereof).
When the underlying lock is an RLock, it is not released using its
release() method, since this may not actually unlock the lock when it
was acquired multiple times recursively. Instead, an internal interface
of the RLock class is used, which really unlocks it even when it has
been recursively acquired several times. Another internal interface is
then used to restore the recursion level when the lock is reacquired.
scannot wait on un-acquired lockg�Mb@?iig����N(RAR7R(R3RGtappendR@R"t_timeRLtmint_sleeptremovet
ValueErrorR?(Rttimeouttwaitertsaved_statetendtimetdelaytgotitt remaining((s/sys/lib/python2.7/threading.pytwait4s8
icCs�|j�std��n|j}|| }|s8dS|jd|||dkrYdp\d�x=|D]5}|j�y|j|�Wqgtk
r�qgXqgWdS(sKWake up one or more threads waiting on this condition, if any.
If the calling thread has not acquired the lock when this method is
called, a RuntimeError is raised.
This method wakes up at most n of the threads waiting for the condition
variable; it is a no-op if no threads are waiting.
s!cannot notify on un-acquired lockNs"%s.notify(): notifying %d waiter%sitst(RAR7RGRR8RQRR(RtnRGtwaitersRT((s/sys/lib/python2.7/threading.pytnotifyts
cCs|jt|j��dS(s�Wake up all threads waiting on this condition.
If the calling thread has not acquired the lock when this method
is called, a RuntimeError is raised.
N(R_RIRG(R((s/sys/lib/python2.7/threading.pyt notifyAll�sN(R R!RBR"RRCR=R1R@R?RARZR_R`t
notify_all(((s/sys/lib/python2.7/threading.pyRD�s @ cOs
t||�S(sOA factory function that returns a new semaphore.
Semaphores manage a counter representing the number of release() calls minus
the number of acquire() calls, plus an initial value. The acquire() method
blocks if necessary until it can return without making the counter
negative. If not given, value defaults to 1.
(t
_Semaphore(RR'((s/sys/lib/python2.7/threading.pyR
�s RbcBsAeZdZddd�Zdd�ZeZd�Zd�ZRS(s"Semaphores manage a counter representing the number of release() calls
minus the number of acquire() calls, plus an initial value. The acquire()
method blocks if necessary until it can return without making the counter
negative. If not given, value defaults to 1.
icCsJ|dkrtd��ntj||�tt��|_||_dS(Nis$semaphore initial value must be >= 0(RRRRRRt_Semaphore__condt_Semaphore__value(RtvalueR((s/sys/lib/python2.7/threading.pyR�s
cCs]t}|j�x@|jdkr<|s,Pn|jj�qW|jd|_t}WdQX|S(sAcquire a semaphore, decrementing the internal counter by one.
When invoked without arguments: if the internal counter is larger than
zero on entry, decrement it by one and return immediately. If it is zero
on entry, block, waiting until some other thread has called release() to
make it larger than zero. This is done with proper interlocking so that
if multiple acquire() calls are blocked, release() will wake exactly one
of them up. The implementation may pick one at random, so the order in
which blocked threads are awakened should not be relied on. There is no
return value in this case.
When invoked with blocking set to true, do the same thing as when called
without arguments, and return true.
When invoked with blocking set to false, do not block. If a call without
an argument would block, return false immediately; otherwise, do the
same thing as when called without arguments, and return true.
iiN(RKRcRdRZRL(RR4R6((s/sys/lib/python2.7/threading.pyR3�s
cCs1|j�|jd|_|jj�WdQXdS(s�Release a semaphore, incrementing the internal counter by one.
When the counter is zero on entry and another thread is waiting for it
to become larger than zero again, wake up that thread.
iN(RcRdR_(R((s/sys/lib/python2.7/threading.pyR8�s
cCs|j�dS(N(R8(RR:R;R<((s/sys/lib/python2.7/threading.pyR=�sN( R R!RBR"RR3RCR8R=(((s/sys/lib/python2.7/threading.pyRb�s% cOs
t||�S(s�A factory function that returns a new bounded semaphore.
A bounded semaphore checks to make sure its current value doesn't exceed its
initial value. If it does, ValueError is raised. In most situations
semaphores are used to guard resources with limited capacity.
If the semaphore is released too many times it's a sign of a bug. If not
given, value defaults to 1.
Like regular semaphores, bounded semaphores manage a counter representing
the number of release() calls minus the number of acquire() calls, plus an
initial value. The acquire() method blocks if necessary until it can return
without making the counter negative. If not given, value defaults to 1.
(t_BoundedSemaphore(RR'((s/sys/lib/python2.7/threading.pyR�sRfcBs&eZdZddd�Zd�ZRS(s�A bounded semaphore checks to make sure its current value doesn't exceed
its initial value. If it does, ValueError is raised. In most situations
semaphores are used to guard resources with limited capacity.
icCs tj|||�||_dS(N(RbRt_initial_value(RReR((s/sys/lib/python2.7/threading.pyRscCsQ|j�|j|jkr+td��n|jd7_|jj�WdQXdS(s6Release a semaphore, incrementing the internal counter by one.
When the counter is zero on entry and another thread is waiting for it
to become larger than zero again, wake up that thread.
If the number of releases exceeds the number of acquires,
raise a ValueError.
s!Semaphore released too many timesiN(RcRdRgRRR_(R((s/sys/lib/python2.7/threading.pyR8s
N(R R!RBR"RR8(((s/sys/lib/python2.7/threading.pyRfscOs
t||�S(s�A factory function that returns a new event.
Events manage a flag that can be set to true with the set() method and reset
to false with the clear() method. The wait() method blocks until the flag is
true.
(t_Event(RR'((s/sys/lib/python2.7/threading.pyR
sRhcBsPeZdZdd�Zd�Zd�ZeZd�Zd�Z dd�Z
RS(s�A factory function that returns a new event object. An event manages a
flag that can be set to true with the set() method and reset to false
with the clear() method. The wait() method blocks until the flag is true.
cCs/tj||�tt��|_t|_dS(N(RRRRt_Event__condRKt_Event__flag(RR((s/sys/lib/python2.7/threading.pyR0scCs|jj�dS(N(RiR(R((s/sys/lib/python2.7/threading.pyt_reset_internal_locks5scCs|jS(s5Return true if and only if the internal flag is true.(Rj(R((s/sys/lib/python2.7/threading.pytisSet9scCs<|jj�zt|_|jj�Wd|jj�XdS(s�Set the internal flag to true.
All threads waiting for the flag to become true are awakened. Threads
that call wait() once the flag is true will not block at all.
N(RiR3RLRjRaR8(R((s/sys/lib/python2.7/threading.pytset?s
cCs/|jj�z
t|_Wd|jj�XdS(s�Reset the internal flag to false.
Subsequently, threads calling wait() will block until set() is called to
set the internal flag to true again.
N(RiR3RKRjR8(R((s/sys/lib/python2.7/threading.pytclearMs
cCsI|jj�z'|js,|jj|�n|jSWd|jj�XdS(sHBlock until the internal flag is true.
If the internal flag is true on entry, return immediately. Otherwise,
block until another thread calls set() to set the flag to true, or until
the optional timeout occurs.
When the timeout argument is present and not None, it should be a
floating point number specifying a timeout for the operation in seconds
(or fractions thereof).
This method returns the internal flag on exit, so it will always return
True except if a timeout is given and the operation times out.
N(RiR3RjRZR8(RRS((s/sys/lib/python2.7/threading.pyRZZs
N(R R!RBR"RRkRltis_setRmRnRZ(((s/sys/lib/python2.7/threading.pyRh's
is Thread-%dcCstda|tS(Ni(t_counter(ttemplate((s/sys/lib/python2.7/threading.pyt_newnamess
cBs:eZdZeZejZejZ ddddddd�Zd�Ze
d��Zd�Zd�Zd�Zd�Zd�Zd �Zd
�Zd�Zd�Zdd
�Ze
d��Zejd��Ze
d��Zd�ZeZe
d��Zejd��Zd�Zd�Z d�Z!d�Z"RS(sqA class that represents a thread of control.
This class can be safely subclassed in a limited fashion.
cCs�tj||�|dkr%i}n||_t|p=t��|_||_||_|j �|_
d|_t�|_
t|_tt��|_t|_tj|_dS(sCThis constructor should always be called with keyword arguments. Arguments are:
*group* should be None; reserved for future extension when a ThreadGroup
class is implemented.
*target* is the callable object to be invoked by the run()
method. Defaults to None, meaning nothing is called.
*name* is the thread name. By default, a unique name is constructed of
the form "Thread-N" where N is a small decimal number.
*args* is the argument tuple for the target invocation. Defaults to ().
*kwargs* is a dictionary of keyword arguments for the target
invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke
the base class constructor (Thread.__init__()) before doing anything
else to the thread.
N(RRR"t_Thread__targettstrRrt
_Thread__namet
_Thread__argst_Thread__kwargst_set_daemont_Thread__daemonict_Thread__identR
t_Thread__startedRKt_Thread__stoppedRRt_Thread__blockRLt_Thread__initializedt_syststderrt_Thread__stderr(RtgroupttargetR-RR'R((s/sys/lib/python2.7/threading.pyR�s cCs0t|d�r|jj�n|jj�dS(NR}(thasattrR}RR{Rk(R((s/sys/lib/python2.7/threading.pyRk�scCs|jS(N(R}(R((s/sys/lib/python2.7/threading.pyt_block�scCs
t�jS(N(Rtdaemon(R((s/sys/lib/python2.7/threading.pyRx�scCs�d}|jj�rd}n|jr0d}n|jrF|d7}n|jdk ri|d|j7}nd|jj|j|fS(Ntinitialtstartedtstoppeds daemons %ss<%s(%s, %s)>( R{RoR|RyRzR"R/R Ru(Rtstatus((s/sys/lib/python2.7/threading.pyR1�s
cCs�|jstd��n|jj�r6td��nt�|t|<WdQXyt|jd�Wn(tk
r�t�t|=WdQX�nX|jj �dS(s-Start the thread's activity.
It must be called at most once per thread object. It arranges for the
object's run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the
same thread object.
sthread.__init__() not calleds threads can only be started onceN((
R~R7R{Rot_active_limbo_lockt_limbot_start_new_threadt_Thread__bootstrapt ExceptionRZ(R((s/sys/lib/python2.7/threading.pytstart�s
cCs@z&|jr%|j|j|j�nWd|`|`|`XdS(sXMethod representing the thread's activity.
You may override this method in a subclass. The standard run() method
invokes the callable object passed to the object's constructor as the
target argument, if any, with sequential and keyword arguments taken
from the args and kwargs arguments, respectively.
N(RsRvRw(R((s/sys/lib/python2.7/threading.pytrun�s cCs8y|j�Wn#|jr-tdkr-dS�nXdS(N(t_Thread__bootstrap_innerRyRR"(R((s/sys/lib/python2.7/threading.pyt__bootstraps
cCst�|_dS(N(R2Rz(R((s/sys/lib/python2.7/threading.pyt
_set_identsc
Cs�z�|j�|jj�t�|t|j<t|=WdQXtra|jd|�t j
t�ntr�|jd|�t jt�nz�|j
�Wn�tk
r�n�t r�t jjd|jt�f�q�|j�\}}}z�|jd|jdIJ|jdIJxB|rX|jd|jjj|j|jjjfIJ|j}qW|jd||fIJWd~~~XnXWd|j�XWdt�|j�ytt�=WnnXWdQXXdS( Ns(%s.__bootstrap(): registering trace hooks*%s.__bootstrap(): registering profile hooksException in thread %s:
%s
sException in thread s2 (most likely raised during interpreter shutdown):s"Traceback (most recent call last):s File "%s", line %s, in %ss%s: %s(R�R{RmR�R,RzR�R%RRRR#RR�t
SystemExitR�twriteR-t_format_exct_Thread__exc_infoR�ttb_frametf_codetco_filenamet tb_linenotco_namettb_nextt_Thread__exc_cleart
_Thread__stopR2(Rtexc_typet exc_valuetexc_tb((s/sys/lib/python2.7/threading.pyt__bootstrap_innersZ
cCsGt|d�sdS|jj�t|_|jj�|jj�dS(NR}(R�R}R3RLR|RaR8(R((s/sys/lib/python2.7/threading.pyt__stopbs
cCsHyt�tt�=WdQXWn&tk
rCdtjkrD�qDnXdS(sARemove current thread from the dict of currently running threads.Ntdummy_threading(R�R,R2R.Rtmodules(R((s/sys/lib/python2.7/threading.pyt__deletels
cCs�|jstd��n|jj�s6td��n|t�krTtd��n|jj�zz|dkr�xg|js�|jj �qsWnJt
�|}x:|js�|t
�}|dkr�Pn|jj |�q�WWd|jj�XdS(sWait until the thread terminates.
This blocks the calling thread until the thread whose join() method is
called terminates -- either normally or through an unhandled exception
or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a
floating point number specifying a timeout for the operation in seconds
(or fractions thereof). As join() always returns None, you must call
isAlive() after join() to decide whether a timeout happened -- if the
thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will
block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current
thread as that would cause a deadlock. It is also an error to join() a
thread before it has been started and attempts to do so raises the same
exception.
sThread.__init__() not calleds'cannot join thread before it is startedscannot join current threadiN(R~R7R{RoRR}R3R"R|RZRNR8(RRStdeadlineRW((s/sys/lib/python2.7/threading.pytjoin�s(
cCs|jS(s�A string used for identification purposes only.
It has no semantics. Multiple threads may be given the same name. The
initial name is set by the constructor.
(Ru(R((s/sys/lib/python2.7/threading.pyR-�s cCst|�|_dS(N(RtRu(RR-((s/sys/lib/python2.7/threading.pyR-�scCs|jS(s;Thread identifier of this thread or None if it has not been started.
This is a nonzero integer. See the thread.get_ident() function. Thread
identifiers may be recycled when a thread exits and another thread is
created. The identifier is available even after the thread has exited.
(Rz(R((s/sys/lib/python2.7/threading.pytident�s
cCs|jj�o|jS(s�Return whether the thread is alive.
This method returns True just before the run() method starts until just
after the run() method terminates. The module function enumerate()
returns a list of all alive threads.
(R{RoR|(R((s/sys/lib/python2.7/threading.pytisAlive�s cCs|jS(s�A boolean value indicating whether this thread is a daemon thread (True) or not (False).
This must be set before start() is called, otherwise RuntimeError is
raised. Its initial value is inherited from the creating thread; the
main thread is not a daemon thread and therefore all threads created in
the main thread default to daemon = False.
The entire Python program exits when no alive non-daemon threads are
left.
(Ry(R((s/sys/lib/python2.7/threading.pyR��scCsC|jstd��n|jj�r6td��n||_dS(NsThread.__init__() not calleds)cannot set daemon status of active thread(R~R7R{RoRy(Rtdaemonic((s/sys/lib/python2.7/threading.pyR�s
cCs|jS(N(R�(R((s/sys/lib/python2.7/threading.pytisDaemonscCs
||_dS(N(R�(RR�((s/sys/lib/python2.7/threading.pyt setDaemonscCs|jS(N(R-(R((s/sys/lib/python2.7/threading.pytgetNamescCs
||_dS(N(R-(RR-((s/sys/lib/python2.7/threading.pytsetNamesN((#R R!RBRKR~Rtexc_infoR�t exc_clearR�R"RRktpropertyR�RxR1R�R�R�R�R�R�t_Thread__deleteR�R-tsetterR�R�tis_aliveR�R�R�R�R�(((s/sys/lib/python2.7/threading.pyR�s: (
J
#8 cOs
t||�S(s�Factory function to create a Timer object.
Timers 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
(t_Timer(RR'((s/sys/lib/python2.7/threading.pyRs
R�cBs/eZdZgid�Zd�Zd�ZRS(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
cCsAtj|�||_||_||_||_t�|_dS(N(RRtintervaltfunctionRR'R
tfinished(RR�R�RR'((s/sys/lib/python2.7/threading.pyR+s
cCs|jj�dS(s(Stop the timer if it hasn't finished yetN(R�Rm(R((s/sys/lib/python2.7/threading.pytcancel3scCsL|jj|j�|jj�s;|j|j|j�n|jj�dS(N(R�RZR�RoR�RR'Rm(R((s/sys/lib/python2.7/threading.pyR�7s(R R!RBRR�R�(((s/sys/lib/python2.7/threading.pyR�"s t_MainThreadcBs#eZd�Zd�Zd�ZRS(cCsHtj|dd�|jj�|j�t�|tt�<WdQXdS(NR-t
MainThread(RRR{RmR�R�R,R2(R((s/sys/lib/python2.7/threading.pyRBs
cCstS(N(RK(R((s/sys/lib/python2.7/threading.pyRxIscCsJ|j�t�}|rnx|r;|j�t�}qW|j�dS(N(R�t_pickSomeNonDaemonThreadR�R�(RR:((s/sys/lib/python2.7/threading.pyt _exitfuncLs
(R R!RRxR�(((s/sys/lib/python2.7/threading.pyR�@s cCs2x+t�D] }|jr
|j�r
|Sq
WdS(N(R R�R�R"(R:((s/sys/lib/python2.7/threading.pyR�Yst_DummyThreadcBs&eZd�Zd�Zdd�ZRS(cCsTtj|dtd��|`|jj�|j�t�|tt �<WdQXdS(NR-sDummy-%d(
RRRrR}R{RmR�R�R,R2(R((s/sys/lib/python2.7/threading.pyRjs
cCstS(N(RL(R((s/sys/lib/python2.7/threading.pyRxwscCsdS(N((RRS((s/sys/lib/python2.7/threading.pyR�zsN(R R!RRxR"R�(((s/sys/lib/python2.7/threading.pyR�hs
cCs+ytt�SWntk
r&t�SXdS(s�Return the current Thread object, corresponding to the caller's thread of control.
If the caller's thread of control was not created through the threading
module, a dummy thread object with limited functionality is returned.
N(R,R2R.R�(((s/sys/lib/python2.7/threading.pyR�s
cCs%t�tt�tt�SWdQXdS(s�Return the number of Thread objects currently alive.
The returned count is equal to the length of the list returned by
enumerate().
N(R�RIR,R�(((s/sys/lib/python2.7/threading.pyR�scCstj�tj�S(N(R,tvaluesR�(((s/sys/lib/python2.7/threading.pyt
_enumerate�scCs%t�tj�tj�SWdQXdS(s�Return a list of all Thread objects currently alive.
The list includes daemonic threads, dummy thread objects created by
current_thread(), and the main thread. It excludes terminated threads and
threads that have not yet been started.
N(R�R,R�R�(((s/sys/lib/python2.7/threading.pyR �s(R(t_local(RcCs�t�ai}t�}t�xbt�D]W}t|d�rK|j�n||krvt�}||_|||<q)|j�q)Wt j
�tj
�tj|�WdQXdS(NRk(
R(R�RR�R�RkR2RzR�R�RnR,tupdate(t
new_activetcurrenttthreadR�((s/sys/lib/python2.7/threading.pyt_after_fork�s
cCsdtfd��Y}dtfd��Y}dtfd��Y}d}d}d }||�}g}xAt|�D]3}|||�} d
|d| _|j| �qsW||||�}
x"|D]} | j�td�q�W|
j�x|D]} | j�q�
j�dS(
NtBoundedQueuecBs#eZd�Zd�Zd�ZRS(cSsVtj|�t�|_t|j�|_t|j�|_||_t�|_ dS(N(
RRRtmonRR6twctlimitt_dequetqueue(RR�((s/sys/lib/python2.7/threading.pyR�s
cSs�|jj�x9t|j�|jkrH|jd|�|jj�qW|jj|�|jd|t|j��|j j
�|jj�dS(Nsput(%s): queue fulls put(%s): appended, length now %d(R�R3RIR�R�RR�RZRMR6R_R8(Rtitem((s/sys/lib/python2.7/threading.pytput�s
cSs�|jj�x'|js6|jd�|jj�qW|jj�}|jd|t|j��|jj �|jj
�|S(Nsget(): queue emptysget(): got %s, %d left(R�R3R�RR6RZtpopleftRIR�R_R8(RR�((s/sys/lib/python2.7/threading.pytget�s
(R R!RR�R�(((s/sys/lib/python2.7/threading.pyR��s tProducerThreadcBseZd�Zd�ZRS(cSs)tj|dd�||_||_dS(NR-tProducer(RRR�tquota(RR�R�((s/sys/lib/python2.7/threading.pyRs cSshddlm}d}xK||jkrc|d}|jjd|j|f�t|�d�qWdS(Ni�(trandomiis%s.%dg���R�R�R�R�R-RP(RR�tcounter((s/sys/lib/python2.7/threading.pyR� s
(R R!RR�(((s/sys/lib/python2.7/threading.pyR�s tConsumerThreadcBseZd�Zd�ZRS(cSs)tj|dd�||_||_dS(NR-tConsumer(RRR�R9(RR�R9((s/sys/lib/python2.7/threading.pyRs cSs>x7|jdkr9|jj�}|GH|jd|_qWdS(Nii(R9R�R�(RR�((s/sys/lib/python2.7/threading.pyR�s(R R!RR�(((s/sys/lib/python2.7/threading.pyR�s iiisProducer-%dig���(RRtrangeR-RMR�RPR�(R�R�R�tNPtQLtNItQtPtiR:tC((s/sys/lib/python2.7/threading.pyt_test�s(
t__main__(JRBtsysRR�tImportErrorR�R twarningstcollectionsRR�RRNRRPt tracebackRR�t__all__tstart_new_threadR�t
allocate_lockR(t get_identR2terrortThreadErrortfilterwarningstDeprecationWarningRKt_VERBOSEtobjectRR"R#R%RRRRR&RRDR
RbRRfR
RhRpRrR�R,R�RRR�R�R�R�RRRRR�R RR�t _shutdownR�Rt_threading_localR�R�(((s/sys/lib/python2.7/threading.pyt<module>s�
u
�J
K �
% R
|