o $âi¦Ýã@s6dZddlZddlZddlZddlZddlmZ ddl m Z ddl m ZmZzddlmZWney=ddlmZYnwgd¢ZejZejZejZejZz ejZdZe d ¡Wn e yed ZYnwej!Z"zej#Z$Wn e yydZ$Ynwej%Z%[da&da'd d „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ƒ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;„ZOdd?„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$tdur t|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„Z dd„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 „Zd d „Zd d„Z dd„Z dd„Z ddd„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'rW rXzCondition.__exit__cCsd|jt|jƒfS)Nz)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ÚwaiterZ saved_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 „Zd d „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 ÿz Event.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"ÿz Event.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 „Zd d „Zd d„Z dd„Z dd„Z dd„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.waitcCs>|jdvr|j ¡|jdvs|jdkrt‚|jdksJ‚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._releasecsBˆj ‡fdd„|¡sˆ ¡t‚ˆjdkrt‚ˆjdksJ‚dS)Ncs ˆjdkSr2©r–r&r7r&r'Ú¿s zBarrier._wait..rrG)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'Ú *sz,_maintain_shutdown_locks..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„Z e 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â|dusJdƒ‚|duri}|rt|ƒ}ntdƒ}|dur4z |j}|d|›d�7}Wn ty3Ynw||_||_||_||_|durH||_nt ƒj |_d|_ t rUd|_ 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#group argument must be None for nowz 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±Z target_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_lockscCsl|jsJdƒ‚d}|j ¡rd}| ¡|jrd}|jr |d7}|jdur,|d|j7}d|jj|j |fS)Nz Thread.__init__() was not calledÚinitialZstartedZstoppedz daemonz %sz <%s(%s, %s)>) r¿r½r�rÊr¾r¸r¹r>r^rµ)r8Zstatusr&r&r'rD†s  zThread.__repr__c Cs¦|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.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)r8rr r/r0r&r&r'r9Ss  zTimer.__init__cCs|j ¡dS)z)Stop the timer if it hasn't finished yet.N)r r’r7r&r&r'Úcancel[rŽz Timer.cancelcCs:|j |j¡|j ¡s|j|ji|j¤Ž|j ¡dSrQ)r rqrr�r r/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__cCsdSrQr&r7r&r&r'rÛ‰sz_DummyThread._stopcCs|js|j ¡s J‚dSrÉ)r¾r½r�r7r&r&r'rÊŒsz_DummyThread.is_aliveNcCsJdƒ‚)NFzcannot join a dummy threadr&r¢r&r&r'rà�röz_DummyThread.joinrQ)r^r?r@r9rÛrÊràr&r&r&r'r}s  rcCs&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=rr&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$ÿr cOs2trtdƒ‚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}|dusJ‚| ¡sJ‚| ¡t ¡ttƒD]}|ƒq" t �t t ƒ}t   ¡Wdƒn1s>wY|sGdS|D] }|  ¡| ¡qIq))zS Wait until the Python thread state of all non-daemon threads get deleted. NT)Ú _main_threadr¾rr¼r:rOrÛÚreversedrrÙrr®rgrH)ZtlockZ atexit_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�Jt t ƒƒ}|  t ¡|D]}||urF| d¡tƒ}||_|||<q0| d¡| ¡q0t ¡t ¡t  |¡ttƒdkseJ‚WdƒdS1spwYdS)zL Cleanup threading module state that should not exist after a fork. TFrGN)rrÍr;rr=r rr3rÙr’r®rÚupdaterÅrËr¹rÛrÎrgri)Z new_activeZcurrentZthreadsrýrär&r&r'Ú _after_fork.s4  ü       "é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 rr rrrrr rrrrrrr rrZ_threading_localr!Úhasattrr"r&r&r&r'ÚsÎ   ÿ  ÿ  ÿ   v;S)X 6  þ ô,5      / ÿ 5ÿ