AlkantarClanX12

Your IP : 18.116.40.151


Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/threading.cpython-37.opt-1.pyc

B

� f���@s�dZddlZddlZddlZddlmZddl	m
Zddlm
Z
ddlmZmZyddlmZWn ek
r�ddlmZYnXdd	d
ddd
dddddddddddddddgZejZejZejZejZejZ y
ej!Z"Wne#k
r�dZ"YnXej$Z$[da%da&dd�Z'dd�Z(eZ)dd�Z!Gd d!�d!�Z*e*Z+Gd"d
�d
�Z,Gd#d�d�Z-Gd$d�de-�Z.Gd%d�d�Z/Gd&d�d�Z0Gd'd�de1�Z2e�j3Z4e4�d@d)d*�Z5e�a6iZ7iZ8e
�Z9e�a:e;�a<Gd+d�d�Z=Gd,d�de=�Z>Gd-d.�d.e=�Z?Gd/d0�d0e=�Z@d1d�ZAeAZBd2d	�ZCeCZDd3d4�ZEd5d�ZFdd6lmGZGe?�aHd7d8�ZId9d
�ZJydd:lmKZLWn"ek
�rzdd;lMmLZLYnXd<d=�ZNeOed>��r�ejPeNd?�dS)Az;Thread module emulating a subset of Java's threading model.�N)�	monotonic)�
format_exc)�WeakSet)�islice�count)�deque�	get_ident�active_count�	Condition�current_thread�	enumerate�main_thread�TIMEOUT_MAX�Event�Lock�RLock�	Semaphore�BoundedSemaphore�Thread�Barrier�BrokenBarrierError�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/python37/lib64/python3.7/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)rrrr r=scOstdkrt||�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�kwargsrrr rKs	
c@sVeZdZdZdd�Zdd�Zddd	�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.

    cCst�|_d|_d|_dS)Nr)�_allocate_lock�_block�_owner�_count)�selfrrr �__init__bsz_RLock.__init__c	Cs^|j}yt|j}Wntk
r(YnXd|j��r:dnd|jj|jj||j	t
t|��fS)Nz)<%s %s.%s object owner=%r count=%d at %s>�lockedZunlocked)r)�_active�name�KeyErrorr(r-�	__class__�
__module__�__qualname__r*�hex�id)r+�ownerrrr �__repr__gsz_RLock.__repr__T���cCsDt�}|j|kr"|jd7_dS|j�||�}|r@||_d|_|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.

        �)rr)r*r(�acquire)r+�blocking�timeout�me�rcrrr r:vs
z_RLock.acquirecCs<|jt�krtd��|jd|_}|s8d|_|j��dS)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 lockr9N)r)r�RuntimeErrorr*r(�release)r+rrrr r@�sz_RLock.releasecCs|��dS)N)r@)r+�t�v�tbrrr �__exit__�sz_RLock.__exit__cCs|j��|\|_|_dS)N)r(r:r*r))r+�staterrr �_acquire_restore�s
z_RLock._acquire_restorecCs<|jdkrtd��|j}d|_|j}d|_|j��||fS)Nrzcannot release un-acquired lock)r*r?r)r(r@)r+rr6rrr �
_release_save�s

z_RLock._release_savecCs|jt�kS)N)r)r)r+rrr �	_is_owned�sz_RLock._is_ownedN)Tr8)
�__name__r2r3�__doc__r,r7r:�	__enter__r@rDrFrGrHrrrr r&Xs
$
r&c@steZdZdZddd�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�}||_|j|_|j|_y|j|_Wntk
rDYnXy|j|_Wntk
rfYnXy|j|_Wntk
r�YnXt�|_	dS)N)
r�_lockr:r@rG�AttributeErrorrFrH�_deque�_waiters)r+�lockrrr r,�s$zCondition.__init__cCs
|j��S)N)rLrK)r+rrr rK�szCondition.__enter__cGs|jj|�S)N)rLrD)r+r$rrr rD�szCondition.__exit__cCsd|jt|j�fS)Nz<Condition(%s, %d)>)rL�lenrO)r+rrr r7�szCondition.__repr__cCs|j��dS)N)rLr@)r+rrr rG�szCondition._release_savecCs|j��dS)N)rLr:)r+�xrrr rF�szCondition._acquire_restorecCs"|j�d�r|j��dSdSdS)NrFT)rLr:r@)r+rrr rH�s
zCondition._is_ownedcCs�|��std��t�}|��|j�|�|��}d}z:|dkrN|��d}n |dkrd|�d|�}n
|�d�}|S|�|�|s�y|j�|�Wnt	k
r�YnXXdS)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)
rHr?r'r:rO�appendrGrF�remove�
ValueError)r+r<�waiterZsaved_stateZgotitrrr �waits*

zCondition.waitcCs\d}|}|�}xH|sV|dk	rD|dkr0t�|}n|t�}|dkrDP|�|�|�}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)�_timerW)r+Z	predicater<�endtimeZwaittime�resultrrr �wait_for8s


zCondition.wait_forr9c	Csj|��std��|j}tt||��}|s,dSx8|D]0}|��y|�|�Wq2tk
r`Yq2Xq2WdS)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)rHr?rOrN�_islicer@rTrU)r+�nZall_waitersZwaiters_to_notifyrVrrr �notifyOs

zCondition.notifycCs|�t|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)r^rQrO)r+rrr �
notify_allfszCondition.notify_all)N)N)N)r9)rIr2r3rJr,rKrDr7rGrFrHrWr[r^r_Z	notifyAllrrrr r
�s

	
0

	c@s8eZdZdZd
dd�Zddd�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.

    r9cCs&|dkrtd��tt��|_||_dS)Nrz$semaphore initial value must be >= 0)rUr
r�_cond�_value)r+�valuerrr r,~szSemaphore.__init__TNc	Cs�|s|dk	rtd��d}d}|j�jxb|jdkrt|s6P|dk	rf|dkrRt�|}n|t�}|dkrfP|j�|�q&W|jd8_d}WdQRX|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 acquireFrr9T)rUr`rarXrW)r+r;r<r>rYrrr r:�s$
zSemaphore.acquirec	Cs.|j�|jd7_|j��WdQRXdS)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.

        r9N)r`rar^)r+rrr r@�szSemaphore.releasecCs|��dS)N)r@)r+rArBrCrrr rD�szSemaphore.__exit__)r9)TN)	rIr2r3rJr,r:rKr@rDrrrr rrs

-c@s"eZdZdZddd�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.

    r9cCst�||�||_dS)N)rr,�_initial_value)r+rbrrr r,�szBoundedSemaphore.__init__c	CsB|j�2|j|jkrtd��|jd7_|j��WdQRXdS)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 timesr9N)r`rarcrUr^)r+rrr r@�s

zBoundedSemaphore.releaseN)r9)rIr2r3rJr,r@rrrr r�s
c@sFeZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
d�Z	dd
d�Z
dS)rz�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+rrr r,�szEvent.__init__cCs|j�t��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.)rd)r+rrr �is_set�szEvent.is_setc	Cs&|j�d|_|j��WdQRXdS)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`rdr_)r+rrr �setsz	Event.setc	Cs|j�d|_WdQRXdS)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`rd)r+rrr �clearszEvent.clearNc	Cs,|j�|j}|s|j�|�}|SQRXdS)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`rdrW)r+r<Zsignaledrrr rWs
z
Event.wait)N)rIr2r3rJr,rerfZisSetrgrhrWrrrr r�s
c@s�eZdZdZddd�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 awoken once they
    have all made that call.

    NcCs.tt��|_||_||_||_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 used as the
        default for all subsequent 'wait()' calls.

        rN)r
rr`�_action�_timeout�_parties�_stater*)r+�parties�actionr<rrr r,@s	zBarrier.__init__c
Cs�|dkr|j}|j�b|��|j}|jd7_z&|d|jkrL|��n
|�|�|S|jd8_|��XWdQRXdS)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'.

        Nr9)rjr`�_enterr*rk�_release�_wait�_exit)r+r<�indexrrr rWPs	

zBarrier.waitcCs,x|jdkr|j��qW|jdkr(t�dS)N)r8r9r)rlr`rWr)r+rrr rons

zBarrier._entercCs>y"|jr|��d|_|j��Wn|���YnXdS)Nr9)rirlr`r_�_break)r+rrr rpyszBarrier._releasecs4�j��fdd�|�s"���t��jdkr0t�dS)Ncs
�jdkS)Nr)rlr)r+rr �<lambda>��zBarrier._wait.<locals>.<lambda>r)r`r[rtrrl)r+r<r)r+r rq�s
z
Barrier._waitcCs(|jdkr$|jdkr$d|_|j��dS)Nr)r8r9)r*rlr`r_)r+rrr rr�s

z
Barrier._exitc	CsT|j�D|jdkr6|jdkr$d|_q<|jdkr<d|_nd|_|j��WdQRXdS)z�Reset the barrier to the initial state.

        Any threads currently waiting will get the BrokenBarrier exception
        raised.

        rr8���N)r`r*rlr_)r+rrr �reset�s


z
Barrier.resetc	Cs|j�|��WdQRXdS)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`rt)r+rrr �abort�sz
Barrier.abortcCsd|_|j��dS)Nrw)rlr`r_)r+rrr rt�szBarrier._breakcCs|jS)z:Return the number of threads required to trip the barrier.)rk)r+rrr rm�szBarrier.partiescCs|jdkr|jSdS)z>Return the number of threads currently waiting at the barrier.r)rlr*)r+rrr �	n_waiting�s
zBarrier.n_waitingcCs
|jdkS)z0Return True if the barrier is in a broken state.rw)rl)r+rrr �broken�szBarrier.broken)NN)N)rIr2r3rJr,rWrorprqrrrxryrt�propertyrmrzr{rrrr r7s


	c@seZdZdS)rN)rIr2r3rrrr r�s�	Thread-%dcCs
|t�S)N)�_counter)�templaterrr �_newname�sr�c@s�eZdZdZdZejZd6dd�dd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd7dd�Zd8d d!�Zed"d#��Zejd$d#��Zed%d&��Zd'd(�Zd)d*�Zed+d,��Zejd-d,��Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdS)9raA 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.

    FNr)�daemoncCs~|dkri}||_t|pt��|_||_||_|dk	r>||_n
t�j|_d|_	d|_
t�|_d|_
d|_tj|_t�|�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.

        NFT)�_target�strr��_name�_args�_kwargs�	_daemonicrr��_ident�_tstate_lockr�_started�_is_stopped�_initialized�_sys�stderr�_stderr�	_dangling�add)r+�group�targetr/r$r%r�rrr r,�s 
zThread.__init__cCs(|j��|r|��nd|_d|_dS)NT)r�re�_set_tstate_lockr�r�)r+�is_aliverrr re(s


zThread._reset_internal_lockscCs^d}|j��rd}|��|jr$d}|jr2|d7}|jdk	rJ|d|j7}d|jj|j|fS)N�initialZstartedZstoppedz daemonz %sz<%s(%s, %s)>)	r�rfr�r�r�r�r1rIr�)r+Zstatusrrr r74s

zThread.__repr__cCs�|jstd��|j��r td��t�|t|<WdQRXyt|jd�Wn,tk
rtt�t|=WdQRX�YnX|j�	�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 onceNr)
r�r?r�rf�_active_limbo_lock�_limbo�_start_new_thread�
_bootstrap�	ExceptionrW)r+rrr �startBs

zThread.startcCs.z|jr|j|j|j�Wd|`|`|`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 �run[s	z
Thread.runcCs2y|��Wn |jr&tdkr&dS�YnXdS)N)�_bootstrap_innerr�r�)r+rrr r�ls
zThread._bootstrapcCst�|_dS)N)rr�)r+rrr �
_set_ident�szThread._set_identc	Cs8t�|_|j��|js4t�t�|j�WdQRXdS)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�r:r��_shutdown_locks_lock�_shutdown_locksr�)r+rrr r��s

zThread._set_tstate_lockcCs��z`|��|��|j��t�|t|j<t|=WdQRXtrLt	�
t�trZt	�t��zy|�
�Wn�tk
r~Yn�t	r�t	jdk	r�td|jt�ft	jd�n�|jdk	�rT|��\}}}z�td|jd|jd�td|jd�x6|�r&td|jjj|j|jjjf|jd�|j}q�Wtd||f|jd�|j��Wd~~~XYnXWdXWdt� ytt�=WnYnXWdQRXXdS)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�rgr�r.r�r�r!r�rrrr��
SystemExitr��printr/�_format_excr��	_exc_info�tb_frame�f_code�co_filename�	tb_lineno�co_name�tb_next�flushr)r+�exc_type�	exc_valueZexc_tbrrr r��sV




zThread._bootstrap_innerc	Cs>|j}|dk	rd|_d|_|js:t�t�|�WdQRXdS)NT)r�r�r�r�r��discard)r+rPrrr �_stop�szThread._stopc	Cst�tt�=WdQRXdS)zARemove current thread from the dict of currently running threads.N)r�r.r)r+rrr �_delete�szThread._deletecCsZ|jstd��|j��s td��|t�kr2td��|dkrD|��n|jt|d�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
        is_alive() 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 threadNr)r<)r�r?r�rfr�_wait_for_tstate_lock�max)r+r<rrr �join�s


zThread.joinTr8cCs0|j}|dkrn|�||�r,|��|��dS)N)r�r:r@r�)r+�blockr<rPrrr r�szThread._wait_for_tstate_lockcCs|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.

        )r�)r+rrr r/(s	zThread.namecCst|�|_dS)N)r�r�)r+r/rrr r/3scCs|jS)a4Thread identifier of this thread or None if it has not been started.

        This is a nonzero integer. See the 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.

        )r�)r+rrr �ident8s
zThread.identcCs&|js|j��sdS|�d�|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.

        F)r�r�rfr�)r+rrr r�Ds	
zThread.is_alivecCs ddl}|jdtdd�|��S)zhReturn whether the thread is alive.

        This method is deprecated, use is_alive() instead.
        rNz/isAlive() is deprecated, use is_alive() instead�)�
stacklevel)�warnings�warn�PendingDeprecationWarningr�)r+r�rrr �isAliveRs
zThread.isAlivecCs|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 only daemon threads are left.

        )r�)r+rrr r�\s
z
Thread.daemoncCs*|jstd��|j��r td��||_dS)NzThread.__init__() not calledz)cannot set daemon status of active thread)r�r?r�rfr�)r+�daemonicrrr r�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.setName)NNNrN)N)Tr8) rIr2r3rJr�r��exc_infor�r,rer7r�r�r�r�r�r�r�r�r�r�r|r/�setterr�r�r�r�r�r�r�r�rrrr r�s8,B	
&

c@s*eZdZdZd	dd�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

    NcCsFt�|�||_||_|dk	r"|ng|_|dk	r4|ni|_t�|_dS)N)rr,�interval�functionr$r%r�finished)r+r�r�r$r%rrr r,�s
zTimer.__init__cCs|j��dS)z)Stop the timer if it hasn't finished yet.N)r�rg)r+rrr �cancel�szTimer.cancelcCs6|j�|j�|j��s(|j|j|j�|j��dS)N)r�rWr�rfr�r$r%rg)r+rrr r��s
z	Timer.run)NN)rIr2r3rJr,r�r�rrrr r�s
c@seZdZdd�ZdS)�_MainThreadc	CsHtj|ddd�|��|j��|��t�|t|j<WdQRXdS)NZ
MainThreadF)r/r�)	rr,r�r�rgr�r�r.r�)r+rrr r,�s
z_MainThread.__init__N)rIr2r3r,rrrr r��sr�c@s.eZdZdd�Zdd�Zdd�Zd
dd	�ZdS)�_DummyThreadc	CsDtj|td�dd�|j��|��t�|t|j<WdQRXdS)NzDummy-%dT)r/r�)	rr,r�r�rgr�r�r.r�)r+rrr r,�s

z_DummyThread.__init__cCsdS)Nr)r+rrr r��sz_DummyThread._stopcCsdS)NTr)r+rrr r��sz_DummyThread.is_aliveNcCsdS)Nr)r+r<rrr r��sz_DummyThread.join)N)rIr2r3r,r�r�r�rrrr r��sr�cCs&y
tt�Stk
r t�SXdS)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.rr0r�rrrr r�s
c	Cs t�tt�tt�SQRXdS)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�rQr.r�rrrr r	�scCstt���tt���S)N)�listr.�valuesr�rrrr �
_enumerate�sr�c	Cs(t�tt���tt���SQRXdS)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�rrrr r�s)rc	Csntjr
dStj}|��t��xHt�tt�}t��WdQRX|sHPx|D]}|�	�|��qNWq"WdS)zS
    Wait until the Python thread state of all non-daemon threads get deleted.
    N)
�_main_threadr�r�r@r�r�r�r�rhr:)ZtlockZlocksrPrrr �	_shutdown�s	
r�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 r
"s)�_local)rc	Cs�t�ai}ytt�}Wntk
r2t�}YnX|at�at�a	t�|tt
��}|�t�xF|D]>}||kr�|�
d�t�}||_|||<qd|�
d�|��qdWt��t��t�|�WdQRXdS)zL
    Cleanup threading module state that should not exist after a fork.
    TFN)r'r�r.rr0r�r�r�rgr�r��updater�rer�r�r�rh)Z
new_activeZcurrentZthreadsZthreadr�rrr �_after_fork3s0






r��register_at_fork)Zafter_in_child)r})QrJ�os�_os�sysr��_threadZtimerrX�	tracebackrr�Z_weakrefsetr�	itertoolsrr\rr*�_collectionsrrN�ImportError�collections�__all__�start_new_threadr��
allocate_lockr'r�r�errorrrr"rMrrr!rrrr&r#r
rrrrr?r�__next__r~r�r�r.r�r�r�rgr�rrr�r�rZ
currentThreadr	ZactiveCountr�rrr�r�r
r�rZ_threading_localr��hasattrr�rrrr �<module>s�



q'P&O

(5