AlkantarClanX12

Your IP : 3.12.148.180


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/threading.cpython-310.opt-1.pyc

o

7]�f���@s6dZddlZddlZddlZddlZddlmZ	ddl
mZddlm
ZmZzddlmZWney=ddlmZYnwgd�ZejZejZejZejZzejZdZe�d	�Wne yed
ZYnwej!Z"zej#Z$Wne yydZ$Ynwej%Z%[da&da'dd�Z(d
d�Z)dd�Z*dd�Z+eZ,dd�Z#Gdd�d�Z-e-Z.Gdd�d�Z/Gdd�d�Z0Gdd�de0�Z1Gdd�d�Z2Gdd �d �Z3Gd!d"�d"e4�Z5ed#�j6Z7d$d%�Z8e#�a9iZ:iZ;e�Z<e�a=e>�a?d&d'�Z@Gd(d)�d)�ZAz
dd*lmBaCmDZEWn#e�ydd+lFmGZHdd,lmIZIeId-d.�ZDd/d-�ZEd0d1�aCYnwtCZJd2d3�ZKGd4d5�d5eA�ZLGd6d7�d7eA�ZMGd8d9�d9eA�ZNd:d;�ZOd<d=�ZPd>d?�ZQd@dA�ZRdBdC�ZSdDdE�ZTgZUd
aVdFdG�ZWddHlmXZXeM�aYdIdJ�ZZdKdL�Z[zddMlm\Z]Wne�y�ddNl^m]Z]YnwdOdP�Z_e`edQ��r�ejae_dR�dSdS)Sz;Thread module emulating a subset of Java's threading model.�N)�	monotonic)�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_size�
excepthook�ExceptHookArgs�gettrace�
getprofileT�
get_native_idFcC�|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&�0/opt/alt/python310/lib64/python3.10/threading.pyr:�rcC�tS)z;Get the profiler function as set by threading.setprofile().r"r&r&r&r'rD�rcCr!)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_hookr$r&r&r'rHr(rcCr))z6Get the trace function as set by threading.settrace().r+r&r&r&r'rRr*rcOs$tdurt|i|��St|i|��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�kwargsr&r&r'rZs	rc@s^eZdZdZdd�Zdd�Zdd�Zdd
d�ZeZdd
�Z	dd�Z
dd�Zdd�Zdd�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��selfr&r&r'�__init__qs
z_RLock.__init__c	Cs\|j}zt|j}Wn	tyYnwd|j��rdnd|jj|jj||j	t
t|��fS)Nz)<%s %s.%s object owner=%r count=%d at %s>�lockedZunlocked)r5�_active�name�KeyErrorr4r:�	__class__�
__module__�__qualname__r6�hex�id)r8�ownerr&r&r'�__repr__vs�
�z_RLock.__repr__cCs|j��d|_d|_dSr2)r4�_at_fork_reinitr5r6r7r&r&r'rE�s

z_RLock._at_fork_reinitT���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.

        �)rr5r6r4�acquire)r8�blocking�timeout�me�rcr&r&r'rH�s
z_RLock.acquirecCs@|jt�kr
td��|jd|_}|sd|_|j��dSdS)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.

        �cannot release un-acquired lockrGN)r5r�RuntimeErrorr6r4�release)r8rr&r&r'rO�s�z_RLock.releasecC�|��dS�N�rO�r8�t�v�tbr&r&r'�__exit__��z_RLock.__exit__cCs|j��|\|_|_dSrQ)r4rHr6r5)r8�stater&r&r'�_acquire_restore�s
z_RLock._acquire_restorecCs<|jdkr	td��|j}d|_|j}d|_|j��||fS)NrrM)r6rNr5r4rO)r8rrCr&r&r'�
_release_save�s

z_RLock._release_savecCs|jt�kSrQ)r5rr7r&r&r'�	_is_owned�rXz_RLock._is_ownedN�TrF)�__name__r?r@�__doc__r9rDrErH�	__enter__rOrWrZr[r\r&r&r&r'r1gs	
$
r1c@s�eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zddd�Zddd�Z
ddd�Zdd�Zdd�ZdS) 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�|durt�}||_|j|_|j|_z|j|_Wn	ty!Ynwz|j|_Wn	ty1Ynwz|j|_Wn	tyAYnwt�|_	dSrQ)
r�_lockrHrOr[�AttributeErrorrZr\�_deque�_waiters�r8�lockr&r&r'r9�s*���zCondition.__init__cCs|j��|j��dSrQ)rarErd�clearr7r&r&r'rEs
zCondition._at_fork_reinitcCs
|j��SrQ)rar`r7r&r&r'r`�
zCondition.__enter__cGs|jj|�SrQ)rarW)r8r/r&r&r'rWrXzCondition.__exit__cCsd|jt|j�fS)Nz<Condition(%s, %d)>)ra�lenrdr7r&r&r'rDszCondition.__repr__cC�|j��dSrQ)rarOr7r&r&r'r[�zCondition._release_savecCrjrQ)rarH)r8�xr&r&r'rZrkzCondition._acquire_restorecCs|j�d�r
|j��dSdS)NFT)rarHrOr7r&r&r'r\s
zCondition._is_ownedcCs�|��std��t�}|��|j�|�|��}d}z7|dur'|��d}n|dkr2|�d|�}n|�d�}|W|�|�|sRz|j�|�WSt	yQYSwS|�|�|slz|j�|�Wwt	ykYwww)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)
r\rNr3rHrd�appendr[rZ�remove�
ValueError)r8rJ�waiterZsaved_stateZgotitr&r&r'�wait s>

��
���zCondition.waitcCs^d}|}|�}|s-|dur#|durt�|}n|t�}|dkr#	|S|�|�|�}|r	|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)�_timerq)r8Z	predicaterJ�endtimeZwaittime�resultr&r&r'�wait_forPs

��
zCondition.wait_forrGcCs�|��std��|j}|rB|dkrD|d}z|��Wn	ty$Ynw|d8}z|�|�Wn	ty9Ynw|rF|dksdSdSdSdS)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 lockrrGN)r\rNrdrOrnro)r8�n�waitersrpr&r&r'�notifygs"
���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)rxrirdr7r&r&r'�
notify_all�szCondition.notify_allcCs$ddl}|jdtdd�|��dS)zvWake up all threads waiting on this condition.

        This method is deprecated, use notify_all() instead.

        rNz3notifyAll() is deprecated, use notify_all() instead���
stacklevel)�warnings�warn�DeprecationWarningry�r8r}r&r&r'�	notifyAll�s
�zCondition.notifyAllrQ�rG)r^r?r@r_r9rEr`rWrDr[rZr\rqrurxryr�r&r&r&r'r	�s

	
0
	r	c@s:eZdZdZd
dd�Zddd�ZeZd
d	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.

    rGcCs&|dkrtd��tt��|_||_dS)Nrz$semaphore initial value must be >= 0)ror	r�_cond�_value�r8�valuer&r&r'r9�s
zSemaphore.__init__TNcCs�|s
|dur
td��d}d}|j�M|jdkr=|sn4|dur2|dur(t�|}n
|t�}|dkr2n$|j�|�|jdks|jd8_d}Wd�|SWd�|SWd�|S1sawY|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 acquireFrrGT)ror�r�rrrq)r8rIrJrLrsr&r&r'rH�s8


�
��
��
��zSemaphore.acquirecCsb|dkrtd��|j�|j|7_t|�D]}|j��qWd�dS1s*wYdS)z�Release a semaphore, incrementing the internal counter by one or more.

        When the counter is zero on entry and another thread is waiting for it
        to become larger than zero again, wake up that thread.

        rG�n must be one or moreN)ror�r��rangerx�r8rv�ir&r&r'rO�s�"�zSemaphore.releasecCrPrQrRrSr&r&r'rW�rXzSemaphore.__exit__r�)TN)	r^r?r@r_r9rHr`rOrWr&r&r&r'r�s

-
rc@s$eZdZdZddd�Zddd�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.

    rGcCst�||�||_dSrQ)rr9�_initial_valuer�r&r&r'r9��
zBoundedSemaphore.__init__cCsz|dkrtd��|j�(|j||jkrtd��|j|7_t|�D]}|j��q#Wd�dS1s6wYdS)a>Release a semaphore, incrementing the internal counter by one or more.

        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.

        rGr�z!Semaphore released too many timesN)ror�r�r�r�rxr�r&r&r'rOs
�"�zBoundedSemaphore.releaseNr�)r^r?r@r_r9rOr&r&r&r'r�s
rc@sJeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
dS)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��_flagr7r&r&r'r9!r�zEvent.__init__cCrjrQ)r�rEr7r&r&r'rE%�zEvent._at_fork_reinitcC�|jS)z5Return true if and only if the internal flag is true.)r�r7r&r&r'�is_set)szEvent.is_setcCs ddl}|jdtdd�|��S)zyReturn true if and only if the internal flag is true.

        This method is deprecated, use is_set() instead.

        rNz+isSet() is deprecated, use is_set() insteadrzr{)r}r~rr�r�r&r&r'�isSet-s
�zEvent.isSetcCs<|j�d|_|j��Wd�dS1swYdS)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�ryr7r&r&r'�set8s"�z	Event.setcCs2|j�d|_Wd�dS1swYdS)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�r7r&r&r'rgCs"�zEvent.clearNcCsD|j�|j}|s|j�|�}|Wd�S1swYdS)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�rq)r8rJZsignaledr&r&r'rqMs$�z
Event.waitrQ)r^r?r@r_r9rEr�r�r�rgrqr&r&r&r'rs

rc@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�_stater6)r8�parties�actionrJr&r&r'r9ws	
zBarrier.__init__c
Cs�|dur|j}|j�B|��|j}|jd7_z&|d|jkr&|��n|�|�|W|jd8_|��Wd�S|jd8_|��w1sOwYdS)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'.

        NrG)r�r��_enterr6r��_release�_wait�_exit)r8rJ�indexr&r&r'rq�s"	

�
�zBarrier.waitcCs0|jdvr|j��|jdvs|jdkrt�dS)N�rFrGr)r�r�rqrr7r&r&r'r��s


�
�zBarrier._entercCs6z|jr|��d|_|j��WdS|���)NrG)r�r�r�ry�_breakr7r&r&r'r��szBarrier._releasecs4�j��fdd�|�s���t��jdkrt�dS)Ncs
�jdkSr2�r�r&r7r&r'�<lambda>�s
zBarrier._wait.<locals>.<lambda>r)r�rur�rr��r8rJr&r7r'r��s
�z
Barrier._waitcCs0|jdkr|jdvrd|_|j��dSdSdS)Nrr�)r6r�r�ryr7r&r&r'r��s

�z
Barrier._exitcCsj|j�(|jdkr|jdkrd|_n|jdkrd|_nd|_|j��Wd�dS1s.wYdS)z�Reset the barrier to the initial state.

        Any threads currently waiting will get the BrokenBarrier exception
        raised.

        rrF���N)r�r6r�ryr7r&r&r'�reset�s


�"�z
Barrier.resetcCs4|j�
|��Wd�dS1swYdS)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�r�r7r&r&r'�abort�s
"�z
Barrier.abortcCsd|_|j��dS)Nr�)r�r�ryr7r&r&r'r��szBarrier._breakcCr�)z:Return the number of threads required to trip the barrier.)r�r7r&r&r'r��szBarrier.partiescCs|jdkr|jSdS)z>Return the number of threads currently waiting at the barrier.r)r�r6r7r&r&r'�	n_waiting�s
zBarrier.n_waitingcCs
|jdkS)z0Return True if the barrier is in a broken state.r�r�r7r&r&r'�brokens
zBarrier.broken�NNrQ)r^r?r@r_r9rqr�r�r�r�r�r�r��propertyr�r�r�r&r&r&r'rns"




rc@seZdZdS)rN)r^r?r@r&r&r&r'rsrrGcCs
|t�SrQ)�_counter)Z
name_templater&r&r'�_newnamerhr�cCsdd�tD�}t�|�dS)a!
    Drop any shutdown locks that don't correspond to running threads anymore.

    Calling this from time to time avoids an ever-growing _shutdown_locks
    set when Thread objects are not joined explicitly. See bpo-37788.

    This must be called with _shutdown_locks_lock acquired.
    cSsg|]}|��s|�qSr&)r:)�.0rfr&r&r'�
<listcomp>*sz,_maintain_shutdown_locks.<locals>.<listcomp>N)�_shutdown_locks�difference_update)Z	to_remover&r&r'�_maintain_shutdown_locks s
r�c@seZdZdZdZ		d8dd�dd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zer0dd�Z
dd�Zdd�Zdd�Zdd�Zd9dd�Zd:d"d#�Zed$d%��Zejd&d%��Zed'd(��Zereed)d*��Zd+d,�Zed-d.��Zejd/d.��Zd0d1�Zd2d3�Zd4d5�Zd6d7�ZdS);raA 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�|duri}|r
t|�}ntd�}|dur,z
|j}|d|�d�7}Wn	ty+Ynw||_||_||_||_|dur@||_nt	�j
|_d|_trMd|_
d|_t�|_d|_d|_tj|_t�|_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.

        Nz	Thread-%dz (�)FT)�strr�r^rb�_target�_name�_args�_kwargs�	_daemonicr
r��_ident�_HAVE_THREAD_NATIVE_ID�
_native_id�_tstate_lockr�_started�_is_stopped�_initialized�_sys�stderr�_stderr�_make_invoke_excepthook�_invoke_excepthook�	_dangling�add)r8�group�targetr<r/r0r�Ztarget_namer&r&r'r9;s:
�
zThread.__init__cCsD|j��|r|jdur|j��|j��dSdSd|_d|_dS�NT)r�rEr�rHr�)r8�is_aliver&r&r'�_reset_internal_locksus


�
zThread._reset_internal_lockscCs^d}|j��r	d}|��|jrd}|jr|d7}|jdur%|d|j7}d|jj|j|fS)N�initialZstartedZstoppedz daemonz %sz<%s(%s, %s)>)	r�r�r�r�r�r�r>r^r�)r8Zstatusr&r&r'rD�s

zThread.__repr__cCs�|jstd��|j��rtd��t�|t|<Wd�n1s!wYzt|jd�WntyKt�t|=Wd��1sEwY�w|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�rNr�r��_active_limbo_lock�_limbo�_start_new_thread�
_bootstrap�	Exceptionrqr7r&r&r'�start�s$


�
���zThread.startcCsRz!|jdur|j|ji|j��W|`|`|`dSW|`|`|`dS|`|`|`w)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�r7r&r&r'�run�s	
�z
Thread.runcCs,z|��WdS|jrtdurYdS�rQ)�_bootstrap_innerr�r�r7r&r&r'r��s
zThread._bootstrapcC�t�|_dSrQ)rr�r7r&r&r'�
_set_ident�rXzThread._set_identcCr�rQ)r r�r7r&r&r'�_set_native_id�rXzThread._set_native_idcCsXt�|_|j��|js*t�t�t�|j�Wd�dS1s#wYdSdS)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�rHr��_shutdown_locks_lockr�r�r�r7r&r&r'�_set_tstate_lock�s
"��zThread._set_tstate_lockcCs4zt|��|��tr|��|j��t�|t|j<t	|=Wd�n1s)wYt
r5t�t
�t
r<t�t
�z|��Wn	|�|�YWt�ztt�=WnYWd�dSWd�dS1snwYdSt�ztt�=WnYWd�wWd�w1s�wYwrQ)r�r�r�r�r�r�r�r;r�r�r,r�rr#rr�r�rr7r&r&r'r��sD

�

��(���zThread._bootstrap_innercCsT|j}|durd|_d|_|js(t�t�Wd�dS1s!wYdSdSr�)r�r�r�r�r�rer&r&r'�_stops"��zThread._stopcCs2t�
tt�=Wd�dS1swYdS)zARemove current thread from the dict of currently running threads.N)r�r;rr7r&r&r'�_deletes
"�zThread._deletecCs\|jstd��|j��std��|t�urtd��|dur#|��dS|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.

        �Thread.__init__() not calledz'cannot join thread before it is startedzcannot join current threadNr)rJ)r�rNr�r�r
�_wait_for_tstate_lock�maxr�r&r&r'�join(s

zThread.joinTrFcCs\|j}|dur	dSz|�||�r|��|��WdSWdS|��r-|��|���rQ)r�rHrOr�r:)r8�blockrJrfr&r&r'r�Ns�zThread._wait_for_tstate_lockcCr�)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�r7r&r&r'r<i�	zThread.namecCst|�|_dSrQ)r�r�)r8r<r&r&r'r<tscCr�)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�r7r&r&r'�identys
zThread.identcCr�)z�Native integral thread ID of this thread, or None if it has not been started.

            This is a non-negative integer. See the get_native_id() function.
            This represents the Thread ID as reported by the kernel.

            )r�r7r&r&r'�	native_id�r�zThread.native_idcCs&|js|j��s
dS|�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. See also the module function
        enumerate().

        F)r�r�r�r�r7r&r&r'r��s	
zThread.is_alivecCr�)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�r7r&r&r'r��s
z
Thread.daemoncCs*|jstd��|j��rtd��||_dS)Nr�z)cannot set daemon status of active thread)r�rNr�r�r�)r8�daemonicr&r&r'r��s


cC�ddl}|jdtdd�|jS)zwReturn whether this thread is a daemon.

        This method is deprecated, use the daemon attribute instead.

        rNz:isDaemon() is deprecated, get the daemon attribute insteadrzr{�r}r~rr�r�r&r&r'�isDaemon��
�zThread.isDaemoncC�"ddl}|jdtdd�||_dS)ztSet whether this thread is a daemon.

        This method is deprecated, use the .daemon property instead.

        rNz;setDaemon() is deprecated, set the daemon attribute insteadrzr{r�)r8r�r}r&r&r'�	setDaemon��
�
zThread.setDaemoncCr�)z�Return a string used for identification purposes only.

        This method is deprecated, use the name attribute instead.

        rNz7getName() is deprecated, get the name attribute insteadrzr{�r}r~rr<r�r&r&r'�getName�r�zThread.getNamecCr�)zrSet the name string for this thread.

        This method is deprecated, use the name attribute instead.

        rNz7setName() is deprecated, set the name attribute insteadrzr{r�)r8r<r}r&r&r'�setName�r�zThread.setName)NNNr&NrQr])r^r?r@r_r�r9r�rDr�r�r�r�r�r�r�r�r�r�r�r�r�r<�setterr�r�r�r�r�r�r�r�r&r&r&r'r0sP��:

	
&







r)�_excepthook�_ExceptHookArgs)�print_exception)�
namedtuplerz'exc_type exc_value exc_traceback threadcCst|�SrQ)r�)r/r&r&r'r�scCs�|jtkrdStdurtjdurtj}n|jdur$|jj}|dur#dSndS|jdur0|jj}nt�}td|�d�|dd�t	|j|j
|j|d�|��dS)z9
        Handle uncaught Thread.run() exception.
        NzException in thread �:T��file�flush)r�)
�exc_type�
SystemExitr�r��threadr�r<r�print�_print_exception�	exc_value�
exc_tracebackr�)r/r�r<r&r&r'r�s(

�

��rcsPt�tj��dur
td���durtd��tj�t�t������fdd�}|S)Nzthreading.excepthook is Nonezsys.excepthook is Nonec
s�zczt}|dur
�}tg���|��}||�WnAtyY}z5d|_~�dur1�jdur1�j}n|j}�d|dd��durH�jdurH�j}n�}|���WYd}~n
d}~wwWd}dSWd}dSd}w)NTz"Exception in threading.excepthook:r�)rrr��__suppress_context__r�r�)r��hookr/�excr�Zsys_excepthook�Zlocal_printZ	local_sysZold_excepthookZold_sys_excepthookZsys_exc_infor&r'�invoke_excepthook%s2�����z2_make_invoke_excepthook.<locals>.invoke_excepthook)rr�rN�exc_infor�)rr&rr'r�s r�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�|�||_||_|dur|ng|_|dur|ni|_t�|_dSrQ)rr9�interval�functionr/r0r�finished)r8rrr/r0r&r&r'r9Ss
zTimer.__init__cCs|j��dS)z)Stop the timer if it hasn't finished yet.N)rr�r7r&r&r'�cancel[r�zTimer.cancelcCs:|j�|j�|j��s|j|ji|j��|j��dSrQ)rrqrr�rr/r0r�r7r&r&r'r�_s
z	Timer.runr�)r^r?r@r_r9r	r�r&r&r&r'rJs

rc@seZdZdd�ZdS)�_MainThreadcCsjtj|ddd�|��|j��|��tr|��t�|t	|j
<Wd�dS1s.wYdS)NZ
MainThreadF�r<r�)rr9r�r�r�r�r�r�r�r;r�r7r&r&r'r9js
"�z_MainThread.__init__N)r^r?r@r9r&r&r&r'r
hsr
c@s.eZdZdd�Zdd�Zdd�Zd
dd	�ZdS)�_DummyThreadcCsftj|td�dd�|j��|��tr|��t�|t	|j
<Wd�dS1s,wYdS)NzDummy-%dTr)rr9r�r�r�r�r�r�r�r;r�r7r&r&r'r9s
"�z_DummyThread.__init__cC�dSrQr&r7r&r&r'r��sz_DummyThread._stopcCsdSr�r&r7r&r&r'r��r*z_DummyThread.is_aliveNcCr
rQr&r�r&r&r'r��sz_DummyThread.joinrQ)r^r?r@r9r�r�r�r&r&r&r'r}s

rcCs&ztt�WStyt�YSw)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.

    )r;rr=rr&r&r&r'r
�s

�r
cC�ddl}|jdtdd�t�S)z�Return the current Thread object, corresponding to the caller's thread of control.

    This function is deprecated, use current_thread() instead.

    rNz;currentThread() is deprecated, use current_thread() insteadrzr{)r}r~rr
�r}r&r&r'�
currentThread�r�rcCs8t�tt�tt�Wd�S1swYdS)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�rir;r�r&r&r&r'r�s$�rcCr)zxReturn the number of Thread objects currently alive.

    This function is deprecated, use active_count() instead.

    rNz7activeCount() is deprecated, use active_count() insteadrzr{)r}r~rrrr&r&r'�activeCount�r�rcCstt���tt���SrQ)�listr;�valuesr�r&r&r&r'�
_enumerate�srcCs@t�tt���tt���Wd�S1swYdS)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�rr;rr�r&r&r&r'r�s$�rcOs2trtd��tj|g|�Ri|��}t�|�dS)a�CPython internal: register *func* to be called before joining threads.

    The registered *func* is called with its arguments just before all
    non-daemon threads are joined in `_shutdown()`. It provides a similar
    purpose to `atexit.register()`, but its functions are called prior to
    threading shutdown instead of interpreter shutdown.

    For similarity to atexit, the registered functions are called in reverse.
    z$can't register atexit after shutdownN)�_SHUTTING_DOWNrN�	functools�partial�_threading_atexitsrm)r%�argr0Zcallr&r&r'�_register_atexit�s
r)rcCs�tjrdSdatj}|��t��tt�D]}|�q	t�t	t
�}t
��Wd�n1s2wY|s;dS|D]
}|��|��q=q)zS
    Wait until the Python thread state of all non-daemon threads get deleted.
    NT)
�_main_threadr�rr�rOr��reversedrr�rr�rgrH)ZtlockZatexit_callZlocksrfr&r&r'�	_shutdown�s&	
�
�rcCr))z�Return the main thread object.

    In normal conditions, the main thread is the thread from which the
    Python interpreter was started.
    )rr&r&r&r'rsr)�_local)rcCs�t�ai}ztt�}Wntyt�}Ynw|at�at	�a
t�Bt	t��}|�t
�|D]}||urF|�d�t�}||_|||<q0|�d�|��q0t��t��t�|�Wd�dS1shwYdS)zL
    Cleanup threading module state that should not exist after a fork.
    TFN)rr�r;rr=r
rr3r�r�r�r�updater�r�r�r�r�rg)Z
new_activeZcurrentZthreadsr�r�r&r&r'�_after_fork.s2
�





"�r �register_at_fork)Zafter_in_child)br_�os�_os�sysr��_threadr�timerrrZ_weakrefsetr�	itertoolsrZ_islicerr6�_collectionsrrc�ImportError�collections�__all__�start_new_threadr��
allocate_lockr3r�rr r�rmrb�errorrrr-r
r#r,rrrrrr1r.r	rrrrrNr�__next__r�r�r�r;r�r�r�r�r�r�rr�rr�r�	tracebackr�r�r��__excepthook__r�rr
rr
rrrrrrrrrrrrrrZ_threading_localr �hasattrr!r&r&r&r'�<module>s��
�
�


v;S)X
6��,5
/�5�