AlkantarClanX12

Your IP : 3.133.128.227


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/threading.cpython-34.pyc

�
h f���#@s~dZddlZddlZyddlmZWn"ek
rVddlmZYnXddlm	Z
ddlmZddl
mZmZyddlmZWn"ek
r�ddlmZYnXd	d
ddd
ddddddddddddgZejZejZejZejZejZy
ejZ Wne!k
rSdZ YnXej"Z"[da#da$dd�Z%dd�Z&eZ'dd�ZGdd�d�Z(e(Z)Gdd
�d
�Z*Gd d�d�Z+Gd!d�de+�Z,Gd"d
�d
�Z-Gd#d�d�Z.Gd$d%�d%e/�Z0e�j1Z2e2�d&d'd(�Z3e�a4iZ5iZ6e�Z7Gd)d�d�Z8Gd*d�de8�Z9Gd+d,�d,e8�Z:Gd-d.�d.e8�Z;d/d�Z<e<Z=d0d	�Z>e>Z?d1d2�Z@d3d�ZAdd4lmBZBe:�aCd5d6�ZDd7d8�ZEd9d:�ZFydd;lmGZHWn"ek
rmdd<lImHZHYnXd=d>�ZJdS)?z;Thread module emulating a subset of Java's threading model.�N)�	monotonic)�time)�
format_exc)�WeakSet)�islice�count)�deque�active_count�	Condition�current_thread�	enumerate�Event�Lock�RLock�	Semaphore�BoundedSemaphore�Thread�Barrier�Timer�ThreadError�
setprofile�settrace�local�
stack_sizecCs
|adS)z�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)�
_profile_hook)�func�r�./opt/alt/python34/lib64/python3.4/threading.pyr3scCs
|adS)z�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)�_trace_hook)rrrrr=scOs&tdkrt||�St||�S)a2Factory 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.

    N)�_CRLock�_PyRLock)�args�kwargsrrrrKs	
c@s�eZdZdZdd�Zdd�Zdddd	�ZeZd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�_RLocka,This class implements reentrant lock objects.

    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.

    cCs"t�|_d|_d|_dS)Nr)�_allocate_lock�_block�_owner�_count)�selfrrr�__init__bs	z_RLock.__init__cCsI|j}yt|j}Wntk
r.YnXd|jj||jfS)Nz<%s owner=%r count=%d>)r&�_active�name�KeyError�	__class__�__name__r')r(�ownerrrr�__repr__gs	
z_RLock.__repr__T�cCs_t�}|j|kr+|jd7_dS|jj||�}|r[||_d|_n|S)aAcquire 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.

        When invoked with the floating-point timeout argument set to a positive
        value, block for at most the number of seconds specified by timeout
        and as long as the lock cannot be acquired.  Return true if the lock has
        been acquired, false if the timeout has elapsed.

        r1)�	get_identr&r'r%�acquire)r(�blocking�timeout�me�rcrrrr3ps		z_RLock.acquirecCsX|jt�kr!td��n|jd|_}|sTd|_|jj�ndS)amRelease 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.

        zcannot release un-acquired lockr1N)r&r2�RuntimeErrorr'r%�release)r(rrrrr9�s	z_RLock.releasecCs|j�dS)N)r9)r(�t�v�tbrrr�__exit__�sz_RLock.__exit__cCs#|jj�|\|_|_dS)N)r%r3r'r&)r(�staterrr�_acquire_restore�s
z_RLock._acquire_restorecCsY|jdkrtd��n|j}d|_|j}d|_|jj�||fS)Nrzcannot release un-acquired lock)r'r8r&r%r9)r(rr/rrr�
_release_save�s				
z_RLock._release_savecCs|jt�kS)N)r&r2)r(rrr�	_is_owned�sz_RLock._is_ownedN���)
r.�
__module__�__qualname__�__doc__r)r0r3�	__enter__r9r=r?r@rArrrrr#Xs	$
r#c@s�eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ddd�Zddd�Zddd�Z
dd�ZeZdS)r
ajClass that implements a condition variable.

    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.

    NcCs�|dkrt�}n||_|j|_|j|_y|j|_Wntk
r]YnXy|j|_Wntk
r�YnXy|j|_Wntk
r�YnXt�|_	dS)N)
r�_lockr3r9r@�AttributeErrorr?rA�_deque�_waiters)r(�lockrrrr)�s$	


zCondition.__init__cCs
|jj�S)N)rGrF)r(rrrrF�szCondition.__enter__cGs|jj|�S)N)rGr=)r(r!rrrr=�szCondition.__exit__cCsd|jt|j�fS)Nz<Condition(%s, %d)>)rG�lenrJ)r(rrrr0�szCondition.__repr__cCs|jj�dS)N)rGr9)r(rrrr@�szCondition._release_savecCs|jj�dS)N)rGr3)r(�xrrrr?�szCondition._acquire_restorecCs+|jjd�r#|jj�dSdSdS)NrFT)rGr3r9)r(rrrrA�s
zCondition._is_ownedcCs�|j�std��nt�}|j�|jj|�|j�}d}zW|dkrr|j�d}n0|dkr�|jd|�}n|jd�}|SWd|j|�|s�y|jj|�Wq�t	k
r�Yq�XnXdS)akWait 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 notify_all() 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.

        zcannot wait on un-acquired lockFNTr)
rAr8r$r3rJ�appendr@r?�remove�
ValueError)r(r5�waiterZsaved_stateZgotitrrr�waits*	

	

zCondition.waitcCs�d}|}|�}xh|s|dk	rf|dkrFt�|}qf|t�}|dkrfPqfn|j|�|�}qW|S)z�Wait until a condition evaluates to True.

        predicate should be a callable which result will be interpreted as a
        boolean value.  A timeout may be provided giving the maximum time to
        wait.

        Nr)�_timerR)r(Z	predicater5�endtimeZwaittime�resultrrr�wait_for2s		


zCondition.wait_forr1cCs�|j�std��n|j}tt||��}|sCdSx>|D]6}|j�y|j|�WqJtk
rYqJXqJWdS)aKWake 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.

        z!cannot notify on un-acquired lockN)rAr8rJrI�_islicer9rOrP)r(�nZall_waitersZwaiters_to_notifyrQrrr�notifyIs
	


zCondition.notifycCs|jt|j��dS)z�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)rYrLrJ)r(rrr�
notify_all`szCondition.notify_all)r.rCrDrEr)rFr=r0r@r?rArRrVrYrZZ	notifyAllrrrrr
�s
	0	c@sUeZdZdZddd�Zdddd�ZeZd	d
�Zdd�ZdS)
raGThis class implements semaphore objects.

    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.

    r1cCs:|dkrtd��ntt��|_||_dS)Nrz$semaphore initial value must be >= 0)rPr
r�_cond�_value)r(�valuerrrr)xszSemaphore.__init__TNc
Cs�|r"|dk	r"td��nd}d}|j��x�|jdkr�|sTPn|dk	r�|dkr|t�|}q�|t�}|dkr�Pq�n|jj|�q;W|jd8_d}WdQX|S)a�Acquire 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.

        When invoked with a timeout other than None, it will block for at
        most timeout seconds.  If acquire does not complete successfully in
        that interval, return false.  Return true otherwise.

        Nz.can't specify timeout for non-blocking acquireFrr1T)rPr[r\rSrR)r(r4r5r7rTrrrr3~s$

zSemaphore.acquirec
Cs0|j�!|jd7_|jj�WdQXdS)z�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.

        r1N)r[r\rY)r(rrrr9�s
zSemaphore.releasecCs|j�dS)N)r9)r(r:r;r<rrrr=�szSemaphore.__exit__)	r.rCrDrEr)r3rFr9r=rrrrrls-c@s1eZdZdZddd�Zdd�ZdS)ra�Implements a 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.

    r1cCstj||�||_dS)N)rr)�_initial_value)r(r]rrrr)�szBoundedSemaphore.__init__c
CsQ|j�B|j|jkr+td��n|jd7_|jj�WdQXdS)a6Release 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.

        z!Semaphore released too many timesr1N)r[r\r^rPrY)r(rrrr9�s


zBoundedSemaphore.releaseN)r.rCrDrEr)r9rrrrr�sc@sgeZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
d�Z	dd
d�Z
dS)r
z�Class implementing event objects.

    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.  The flag is initially false.

    cCstt��|_d|_dS)NF)r
rr[�_flag)r(rrrr)�szEvent.__init__cCs|jjt��dS)N)r[r)r)r(rrr�_reset_internal_locks�szEvent._reset_internal_lockscCs|jS)z5Return true if and only if the internal flag is true.)r_)r(rrr�is_set�szEvent.is_setc	Cs*|j�d|_|jj�WdQXdS)z�Set the internal flag to true.

        All threads waiting for it to become true are awakened. Threads
        that call wait() once the flag is true will not block at all.

        TN)r[r_rZ)r(rrr�set�s
	z	Event.setc	Cs|j�d|_WdQXdS)z�Reset the internal flag to false.

        Subsequently, threads calling wait() will block until set() is called to
        set the internal flag to true again.

        FN)r[r_)r(rrr�clears
zEvent.clearNc	Cs<|j�-|j}|s.|jj|�}n|SWdQXdS)aHBlock 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)r[r_rR)r(r5ZsignaledrrrrRs

	z
Event.wait)r.rCrDrEr)r`raZisSetrbrcrRrrrrr
�s
c@s�eZdZdZdddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
dd��Ze
dd��Ze
dd��ZdS)rz�Implements a Barrier.

    Useful for synchronizing a fixed number of threads at known synchronization
    points.  Threads block on 'wait()' and are simultaneously once they have all
    made that call.

    NcCsCtt��|_||_||_||_d|_d|_dS)aWCreate a barrier, initialised to 'parties' threads.

        'action' is a callable which, when supplied, will be called by one of
        the threads after they have all entered the barrier and just prior to
        releasing them all. If a 'timeout' is provided, it is uses as the
        default for all subsequent 'wait()' calls.

        rN)r
rr[�_action�_timeout�_parties�_stater')r(�parties�actionr5rrrr):s					zBarrier.__init__cCs�|dkr|j}n|j�y|j�|j}|jd7_z5|d|jkrg|j�n
|j|�|SWd|jd8_|j�XWdQXdS)aNWait for the barrier.

        When the specified number of threads have started waiting, they are all
        simultaneously awoken. If an 'action' was provided for the barrier, one
        of the threads will have executed that callback prior to returning.
        Returns an individual index number from 0 to 'parties-1'.

        Nr1)rer[�_enterr'rf�_release�_wait�_exit)r(r5�indexrrrrRJs	

	

zBarrier.waitcCsTx |jdkr"|jj�qW|jdkr;t�n|jdksPt�dS)Nr1rrB)rBr1)rgr[rR�BrokenBarrierError�AssertionError)r(rrrrjhs
	zBarrier._enterc	CsLy0|jr|j�nd|_|jj�Wn|j��YnXdS)Nr1)rdrgr[rZ�_break)r(rrrrkss	
	
zBarrier._releasecse�jj�fdd�|�s4�j�t�n�jdkrLt�n�jdksat�dS)Ncs
�jdkS)Nr)rgr)r(rr�<lambda>�szBarrier._wait.<locals>.<lambda>rr1)r[rVrqrorgrp)r(r5r)r(rrl�s!
		z
Barrier._waitcCs>|jdkr:|jdkr:d|_|jj�q:ndS)Nrr1rB)rBr1)r'rgr[rZ)r(rrrrm�s	z
Barrier._exitc	Csr|j�c|jdkrR|jdkr4d|_q[|jdkr[d|_q[n	d|_|jj�WdQXdS)z�Reset the barrier to the initial state.

        Any threads currently waiting will get the BrokenBarrier exception
        raised.

        rr1�NrB���rB)r[r'rgrZ)r(rrr�reset�s
	z
Barrier.resetcCs|j�|j�WdQXdS)z�Place the barrier into a 'broken' state.

        Useful in case of error.  Any currently waiting threads and threads
        attempting to 'wait()' will have BrokenBarrierError raised.

        N)r[rq)r(rrr�abort�s
z
Barrier.abortcCsd|_|jj�dS)Nrsrt)rgr[rZ)r(rrrrq�s	zBarrier._breakcCs|jS)z:Return the number of threads required to trip the barrier.)rf)r(rrrrh�szBarrier.partiescCs|jdkr|jSdS)z>Return the number of threads currently waiting at the barrier.r)rgr')r(rrr�	n_waiting�szBarrier.n_waitingcCs
|jdkS)z0Return True if the barrier is in a broken state.rsrt)rg)r(rrr�broken�szBarrier.broken)r.rCrDrEr)rRrjrkrlrmrurvrq�propertyrhrwrxrrrrr1s
	c@seZdZdS)roN)r.rCrDrrrrro�sroz	Thread-%dcCs|t�S)N)�_counter)�templaterrr�_newname�sr|c	@s�eZdZdZdZejZdddfddddd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zddd�Zdd3dd �Zed!d"��Zejd#d"��Zed$d%��Zd&d'�ZeZed(d)��Zejd*d)��Zd+d,�Zd-d.�Zd/d0�Zd1d2�ZdS)4raA class that represents a thread of control.

    This class can be safely subclassed in a limited fashion. There are two ways
    to specify the activity: by passing a callable object to the constructor, or
    by overriding the run() method in a subclass.

    FN�daemoncCs�|dkstd��|dkr-i}n||_t|pEt��|_||_||_|dk	rx||_nt�j	|_d|_
d|_t�|_
d|_d|_tj|_tj|�dS)aKThis 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.

        Nz#group argument must be None for nowFT)rp�_target�strr|�_name�_args�_kwargs�	_daemonicrr}�_ident�_tstate_lockr
�_started�_is_stopped�_initialized�_sys�stderr�_stderr�	_dangling�add)r(�group�targetr+r!r"r}rrrr)�s"								zThread.__init__cCs6|jj�|r |j�nd|_d|_dS)NT)r�r`�_set_tstate_lockr�r�)r(�is_aliverrrr`s


	zThread._reset_internal_lockscCs�|jstd��d}|jj�r3d}n|j�|jrOd}n|jre|d7}n|jdk	r�|d|j7}nd|jj	|j
|fS)Nz Thread.__init__() was not called�initialZstartedZstoppedz daemonz %sz<%s(%s, %s)>)r�rpr�rar�r�r�r�r-r.r�)r(Zstatusrrrr0)s	
			
zThread.__repr__cCs�|jstd��n|jj�r6td��nt�|t|<WdQXyt|jf�Wn)tk
r�t�t|=WdQX�YnX|jj	�dS)a-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.

        zthread.__init__() not calledz threads can only be started onceN)
r�r8r�ra�_active_limbo_lock�_limbo�_start_new_thread�
_bootstrap�	ExceptionrR)r(rrr�start7s
	

zThread.startc
Cs@z&|jr%|j|j|j�nWd|`|`|`XdS)aXMethod 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)r~r�r�)r(rrr�runPs		z
Thread.runc	Cs9y|j�Wn$|jr-tdkr-dS�YnXdS)N)�_bootstrap_innerr�r�)r(rrrr�as
zThread._bootstrapcCst�|_dS)N)r2r�)r(rrr�
_set_identuszThread._set_identcCst�|_|jj�dS)z�
        Set a lock object which will be released by the interpreter when
        the underlying thread state (see pystate.h) gets deleted.
        N)�
_set_sentinelr�r3)r(rrrr�xszThread._set_tstate_lockc1Cs�z�|j�|j�|jj�t�|t|j<t|=WdQXtr[t	j
t�ntrqt	jt�nz:y|j
�Wn%tk
r�Ynt	r�t	jdk	r�td|jt�fd|j�n�|jdk	r�|j�\}}}z�td|jdd|j�tdd|j�xH|rvtd|jjj|j|jjjfd|j�|j}q/Wtd||fd|j�Wd~~~XnYnXWdXWdt�ytt�=WnYnXWdQXXdS)NzException in thread %s:
%s�filezException in thread z2 (most likely raised during interpreter shutdown):z"Traceback (most recent call last):z  File "%s", line %s, in %sz%s: %s)r�r�r�rbr�r*r�r�rr�rrrr��
SystemExitr��printr+�_format_excr��	_exc_info�tb_frame�f_code�co_filename�	tb_lineno�co_name�tb_nextr2)r(�exc_type�	exc_valueZexc_tbrrrr��sT





 
	
!zThread._bootstrap_innercCsA|j}|dk	r+|j�s+t�nd|_d|_dS)NT)r��lockedrpr�)r(rKrrr�_stop�s
		zThread._stopcCsIyt�tt�=WdQXWn'tk
rDdtjkr@�nYnXdS)zARemove current thread from the dict of currently running threads.NZdummy_threading)r�r*r2r,r��modules)r(rrr�_delete�s
zThread._deletecCs�|jstd��n|jj�s6td��n|t�krTtd��n|dkrm|j�n|jdt|d��dS)aWait 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.

        zThread.__init__() not calledz'cannot join thread before it is startedzcannot join current threadNr5r)r�r8r�rar�_wait_for_tstate_lock�max)r(r5rrr�join�s	
zThread.joinTr1cCsT|j}|dkr'|jsPt�n)|j||�rP|j�|j�ndS)N)r�r�rpr3r9r�)r(�blockr5rKrrrr�!s	
zThread._wait_for_tstate_lockcCs|jstd��|jS)z�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.

        zThread.__init__() not called)r�rpr�)r(rrrr+/szThread.namecCs(|jstd��t|�|_dS)NzThread.__init__() not called)r�rprr�)r(r+rrrr+:scCs|jstd��|jS)a;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.

        zThread.__init__() not called)r�rpr�)r(rrr�ident?s	zThread.identcCsG|jstd��|js.|jj�r2dS|jd�|jS)z�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.

        zThread.__init__() not calledF)r�rpr�r�rar�)r(rrrr�Ks

zThread.is_alivecCs|jstd��|jS)a�A boolean value indicating whether this thread is a daemon thread.

        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.

        zThread.__init__() not called)r�rpr�)r(rrrr}[s
z
Thread.daemoncCsC|jstd��n|jj�r6td��n||_dS)NzThread.__init__() not calledz)cannot set daemon status of active thread)r�r8r�rar�)r(�daemonicrrrr}ks
	cCs|jS)N)r})r(rrr�isDaemonsszThread.isDaemoncCs
||_dS)N)r})r(r�rrr�	setDaemonvszThread.setDaemoncCs|jS)N)r+)r(rrr�getNameyszThread.getNamecCs
||_dS)N)r+)r(r+rrr�setName|szThread.setNamerB) r.rCrDrEr�r��exc_infor�r)r`r0r�r�r�r�r�r�r�r�r�r�ryr+�setterr�r�ZisAliver}r�r�r�r�rrrrr�s8		,A#&c@s@eZdZdZdddd�Zdd�Zdd�ZdS)	rz�Call a function after a specified number of seconds:

            t = Timer(30.0, f, args=None, kwargs=None)
            t.start()
            t.cancel()     # stop the timer's action if it's still waiting

    NcCsetj|�||_||_|dk	r1|ng|_|dk	rL|ni|_t�|_dS)N)rr)�interval�functionr!r"r
�finished)r(r�r�r!r"rrrr)�s
		zTimer.__init__cCs|jj�dS)z)Stop the timer if it hasn't finished yet.N)r�rb)r(rrr�cancel�szTimer.cancelcCsL|jj|j�|jj�s;|j|j|j�n|jj�dS)N)r�rRr�rar�r!r"rb)r(rrrr��sz	Timer.run)r.rCrDrEr)r�r�rrrrr�sc@seZdZdd�ZdS)�_MainThreadc
CsXtj|dddd�|j�|jj�|j�t�|t|j<WdQXdS)Nr+Z
MainThreadr}F)	rr)r�r�rbr�r�r*r�)r(rrrr)�s


z_MainThread.__init__N)r.rCrDr)rrrrr��sr�c@s7eZdZdd�Zdd�Zddd�ZdS)�_DummyThreadc
CsTtj|dtd�dd�|jj�|j�t�|t|j<WdQXdS)Nr+zDummy-%dr}T)	rr)r|r�rbr�r�r*r�)r(rrrr)�s


z_DummyThread.__init__cCsdS)Nr)r(rrrr��sz_DummyThread._stopNcCsdstd��dS)NFzcannot join a dummy thread)rp)r(r5rrrr��sz_DummyThread.join)r.rCrDr)r�r�rrrrr��sr�cCs/ytt�SWntk
r*t�SYnXdS)z�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�rrrrr�s
c
Cs%t�tt�tt�SWdQXdS)z�Return the number of Thread objects currently alive.

    The returned count is equal to the length of the list returned by
    enumerate().

    N)r�rLr*r�rrrrr	�scCs ttj��ttj��S)N)�listr*�valuesr�rrrr�
_enumerate�sr�c
Cs1t�%ttj��ttj��SWdQXdS)z�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�r�rrrrr�s)rcCsxtj}|dk	st�|j�s-t�|j�tj�t�}x|ri|j�t�}qMWtj�dS)N)	�_main_threadr�rpr�r9r��_pickSomeNonDaemonThreadr�r�)Ztlockr:rrr�	_shutdown�s	

		

r�cCs2x+t�D] }|jr
|j�r
|Sq
WdS)N)rr}r�)r:rrrr�	sr�cCstS)z�Return the main thread object.

    In normal conditions, the main thread is the thread from which the
    Python interpreter was started.
    )r�rrrr�main_threadsr�)�_local)rcCs�t�ai}t�}|at��tt��}|jt�x]|D]U}||kr�|jd�t	�}||_
|||<qH|jd�|j�qHWtj
�tj
�tj|�tt�dks�t�WdQXdS)NTFr1)r$r�rr�rbr��updater�r`r2r�r�r�rcr*rLrp)Z
new_activeZcurrentZthreadsZthreadr�rrr�_after_fork s&		


		




r�)KrE�sysr��_threadrrrS�ImportError�	tracebackrr��_weakrefsetr�	itertoolsrrWrr'�_collectionsrrI�collections�__all__�start_new_threadr��
allocate_lockr$r�r2�errorrrrrH�TIMEOUT_MAXrrrrrr#r r
rrr
rr8ro�__next__rzr|r�r*r�r�rrr�r�rZ
currentThreadr	ZactiveCountr�rrr�r�r�r�r�rZ_threading_localr�rrrr�<module>s�

					

	

k�P&O�		��