Qf'dZddlZddlZddlZddlZddlmZ ddl m Z ddl m Z ddlmZgdZej*Zej.Zej2Zej6Zej8Z ej:Z ej>Zd Z ejCd ejDZ# ejHZ%ejLZ&[da'da(d Z)d Z*dZ+dZ,dZ-dZ.eZ/dZ$GddZ0e0Z1GddZ2GddZ3Gdde3Z4GddZ5GddZ6Gdd e7Z8ed!jrZ:d"Z;e$ae Z?ea@eAaBd#ZCGd$d%ZD dd&lmEaFmGZHtZMd-ZNGd.d/eDZOGd0d1eDZPGd2d3eDZQd4ZRd5ZSd6ZTd7ZUd8ZVd9ZWgZXd aYd:ZZdd;lm[Z[ePa\d<Z]d=Z^ dd>lm_Z`d@ZbecedArejebByy#e$r ddlmZYwxYw#e$rdZYwxYw#e$rd Z YwxYw#e$rdZ%YtwxYw#e$rdd'lImJZKdd(lmLZLeLd)d*ZGd+ZHd,aFYwxYw#e$r dd?lam`Z`YwxYw)Cz;Thread module emulating a subset of Java's threading model.N) monotonic)WeakSet)count)deque) get_ident active_count Conditioncurrent_thread enumerate main_thread TIMEOUT_MAXEventLockRLock SemaphoreBoundedSemaphoreThreadBarrierBrokenBarrierErrorTimer ThreadError setprofilesettracelocal stack_size excepthookExceptHookArgsgettrace getprofilesetprofile_all_threadssettrace_all_threadscyNTr$0/opt/alt/python312/lib64/python3.12/threading.py_is_main_interpreterr'4sr%T get_native_idFc|ay)zSet 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_hookfuncs r&rrJs Mr%cDt|tj|y)zSet a profile function for all threads started from the threading module and all Python threads that are currently executing. The func will be passed to sys.setprofile() for each thread, before its run() method is called. N)r_sys_setprofileallthreadsr,s r&r r Sstt$r%ctS)z;Get the profiler function as set by threading.setprofile().r*r$r%r&rr]s r%c|ay)zSet 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,s r&rras Kr%cDt|tj|y)zSet a trace function for all threads started from the threading module and all Python threads that are currently executing. The func will be passed to sys.settrace() for each thread, before its run() method is called. N)rr/_settraceallthreadsr,s r&r!r!js TNT"r%ctS)z6Get the trace function as set by threading.settrace().r3r$r%r&rrts r%c:t 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. )_CRLock_PyRLock)argskwargss r&rr|s)((( D #F ##r%cReZdZdZdZdZdZd dZeZdZ dZ dZ d Z d Z d Zy )_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. c>t|_d|_d|_yNr)_allocate_lock_block_owner_countselfs r&__init__z_RLock.__init__s$&   r%c 6|j} t|j}d|jj rdnd|j j|j j||jtt|fzS#t$rYvwxYw)Nz)<%s %s.%s object owner=%r count=%d at %s>lockedunlocked) rC_activenameKeyErrorrBrI __class__ __module__ __qualname__rDhexid)rFowners r&__repr__z_RLock.__repr__s  EN''E; **,H* NN % % NN ' '  KK 4M >      sB BBcT|jjd|_d|_yr@)rB_at_fork_reinitrCrDrEs r&rVz_RLock._at_fork_reinits  ##%  r%ct}|j|k(r|xjdz c_y|jj ||}|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. )rrCrDrBacquire)rFblockingtimeoutmercs r&rYz_RLock.acquiresT4[ ;;"  KK1 K [[ 7 3 DKDK r%c|jtk7r td|jdz x|_}|s"d|_|jj yy)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 lockrXN)rCr RuntimeErrorrDrBrelease)rFrs r&raz_RLock.releasesQ ;;)+ %@A A"kkAo- eDK KK   !r%c$|jyNrarFtvtbs r&__exit__z_RLock.__exit__  r%cV|jj|\|_|_yrc)rBrYrDrC)rFstates r&_acquire_restorez_RLock._acquire_restores  #(  T[r%c|jdk(r td|j}d|_|j}d|_|jj ||fS)Nrr_)rDr`rCrBra)rFrrSs r& _release_savez_RLock._release_savesT ;;! @A A     u~r%c0|jtk(Src)rCrrEs r& _is_ownedz_RLock._is_owneds{{ik))r%cJ|jtk7ry|jSr@)rCrrDrEs r&_recursion_countz_RLock._recursion_counts ;;)+ %{{r%NT)__name__rOrP__doc__rGrTrVrY __enter__rarirmrorqrsr$r%r&r>r>sA   "HI". )* r%r>cfeZdZdZddZdZdZdZdZdZ d Z d Z dd Z dd Z dd ZdZdZy)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. Nc:| t}||_|j|_|j|_t |dr|j |_t |dr|j |_t |dr|j|_t|_ y)Nrormrq) r_lockrYrahasattrrormrq_deque_waitersrFlocks r&rGzCondition.__init__s| <7D || ||  4 )!%!3!3D  4+ ,$($9$9D ! 4 %!^^DN r%cl|jj|jjyrc)r{rVr~clearrEs r&rVzCondition._at_fork_reinit's" ""$ r%c6|jjSrc)r{rxrEs r&rxzCondition.__enter__+szz##%%r%c4|jj|Src)r{ri)rFr;s r&rizCondition.__exit__.s"tzz""D))r%cJd|jt|jfzS)Nz)r{lenr~rEs r&rTzCondition.__repr__1s$ C 4F'GGGr%c8|jjyrc)r{rarEs r&rozCondition._release_save4 r%c8|jjyrc)r{rY)rFxs r&rmzCondition._acquire_restore7rr%cp|jjdr|jjyy)NFT)r{rYrarEs r&rqzCondition._is_owned:s, ::  e $ JJ   r%cN|js tdt}|j|jj ||j }d} ||jd}n)|dkDr|jd|}n|jd}||j||s |jj|SS#t$rYSwxYw#|j||s, |jj|w#t$rYwwxYwwxYw)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 lockFTr) rqr`rArYr~appendrormremove ValueError)rFr[waiter saved_stategotits r&waitzCondition.waitCs.~~@A A! V$((*   Q;"NN49E"NN51E  ! !+ .MM((0"  ! !+ .MM((0!sB$?C#7C C C #D$8DD$ D D$D  D$cd}|}|}|sB|%|t|z}n|tz }|dkr |S|j||}|sB|S)zWait 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)_timer)rF predicater[endtimewaittimeresults r&wait_forzCondition.wait_forssm#?#g0G&0H1}  IIh [F r%c |js td|j}|r=|dkDr7|d} |j|dz} |j ||r|dkDr5yyyy#t$rY)wxYw#t $rY&wxYw)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 lockrrXN)rqr`r~rarr)rFnwaitersrs r&notifyzCondition.notifys~~BC C--!a%QZF  Q v&!a%g%g       s#A( A7( A43A47 BBcL|jt|jy)zWake 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)rrr~rEs r& notify_allzCondition.notify_alls C &'r%c\ddl}|jdtd|jy)zvWake up all threads waiting on this condition. This method is deprecated, use notify_all() instead. rNz3notifyAll() is deprecated, use notify_all() instead stacklevel)warningswarnDeprecationWarningrrFrs r& notifyAllzCondition.notifyAlls*  K(Q  8 r%rcrX)rvrOrPrwrGrVrxrirTrormrqrrrrrr$r%r&r r sJ !$&*H.`.<( r%r c8eZdZdZddZdZd dZeZddZdZ y) 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. cb|dkr tdtt|_||_y)Nrz$semaphore initial value must be >= 0)rr r_cond_value)rFvalues r&rGzSemaphore.__init__s* 19CD Dtv&  r%c |j}d|jd|jdt|dd|jd S)N<. at #x: value=>)rNrOrPrRrrFclss r&rTzSemaphore.__repr__sKnnCNN#1S%5%5$6d2d8B-H++a) *r%Ncb|s | tdd}d}|j5|jdk(rS|sng|#|t|z}n|tz }|dkrnB|jj ||jdk(rS|xjdzc_d}ddd|S#1swY|SxYw)aAcquire 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 acquireFrrXT)rrrrr)rFrZr[r]rs r&rYzSemaphore.acquires0G/MN N  ZZ++"&"''G"3")EG"3"a<! (++" q   sA"B$B$$B.c|dkr td|j5|xj|z c_|jj|dddy#1swYyxYw)zRelease 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. rXn must be one or moreN)rrrrrFrs r&razSemaphore.releasesH q545 5 ZZ KK1 K JJ  a ZZs 1AA c$|jyrcrdres r&rizSemaphore.__exit__rjr%r)TN) rvrOrPrwrGrTrYrxrarir$r%r&rrs( * +ZI !r%rc2eZdZdZdfd ZdZddZxZS)raImplements 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. c2t||||_yrc)superrG_initial_value)rFrrNs r&rGzBoundedSemaphore.__init__%s #r%c |j}d|jd|jdt|dd|jd|j d S)Nrrrrr/r)rNrOrPrRrrrs r&rTzBoundedSemaphore.__repr__)sYnnCNN#1S%5%5$6d2d8B-H++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. rXrz!Semaphore released too many timesN)rrrrrrs r&razBoundedSemaphore.release.sj q545 5 ZZ{{Q!4!44 !DEE KK1 K JJ  a ZZs AA>>Br)rvrOrPrwrGrTra __classcell__)rNs@r&rrs $@ !r%rcBeZdZdZdZdZdZdZdZdZ dZ d d Z y ) rzClass 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. cBtt|_d|_y)NF)r rr_flagrEs r&rGzEvent.__init__Lstv&  r%c |j}|jrdnd}d|jd|jdt |dd|d S) Nsetunsetrrrrz: r)rNrrOrPrR)rFrstatuss r&rTzEvent.__repr__PsLnn**'3>>"!C$4$4#5T"T(2bPQRRr%c8|jjyrc)rrVrEs r&rVzEvent._at_fork_reinitUs ""$r%c|jS)z5Return true if and only if the internal flag is true.)rrEs r&is_setz Event.is_setYs zzr%cZddl}|jdtd|jS)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() insteadrr)rrrrrs r&isSetz Event.isSet]s,  C(Q  8{{}r%c|j5d|_|jjdddy#1swYyxYw)zSet 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)rrrrEs r&rz Event.seths,ZZDJ JJ ! ! #ZZs "8AcT|j5d|_dddy#1swYyxYw)zReset the internal flag to false. Subsequently, threads calling wait() will block until set() is called to set the internal flag to true again. FN)rrrEs r&rz Event.clearssZZDJZZs'Nc|j5|j}|s|jj|}|cdddS#1swYyxYw)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)rrr)rFr[signaleds r&rz Event.wait}s;ZZzzH::??73   ZZs +AA rc) rvrOrPrwrGrTrVrrrrrr$r%r&rrAs0S %  $r%rceZdZdZddZdZddZdZdZdZ d Z d Z d Z d Z ed ZedZedZy)rzImplements 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. Nc|dkr tdtt|_||_||_||_d|_d|_y)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. rXzparties must be > 0rN) rr rr_action_timeout_parties_staterD)rFpartiesactionr[s r&rGzBarrier.__init__sH Q;23 3tv&      r%c |j}|jr*d|jd|jdt |ddSd|jd|jdt |dd|j d|j d S) Nrrrrz : broken>z : waiters=rr)rNbrokenrOrPrR n_waitingrrs r&rTzBarrier.__repr__snn ;;s~~&a(8(8'9bhr])T TCNN#1S%5%5$6d2d8B-H NN+1T\\N!= >r%c| |j}|j5|j|j}|xjdz c_ |dz|jk(r|j n|j |||xjdzc_|jcdddS#|xjdzc_|jwxYw#1swYyxYw)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'. NrX)rr_enterrDr_release_wait_exit)rFr[indexs r&rz Barrier.waits ?mmG ZZ KKMKKE KK1 K 19 -MMOJJw' q     q  Zs#2C5B2%C2'CCC%c|jdvr)|jj|jdvr)|jdkrty)NrurXr)rrrrrEs r&rzBarrier._entersBkkW$ JJOO kkW$ ;;?$ $ r%c |jr|jd|_|jjy#|j xYw)NrX)rrrr_breakrEs r&rzBarrier._releasesA || DK JJ ! ! #  KKM s =AAcjjfd|sjtjdkrty)Nc"jdk7Sr@rrEsr&zBarrier._wait..sDKK1,cf|j5|jdddy#1swYyxYw)zPlace 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)rrrEs r&abortz Barrier.abortsZZ KKMZZs'0cFd|_|jjy)Nr)rrrrEs r&rzBarrier._break's  r%c|jS)z:Return the number of threads required to trip the barrier.)rrEs r&rzBarrier.parties-s}}r%c:|jdk(r |jSy)z>Return the number of threads currently waiting at the barrier.r)rrDrEs r&rzBarrier.n_waiting2s ;;! ;; r%c |jdk(S)z0Return True if the barrier is in a broken state.rrrEs r&rzBarrier.broken;s{{b  r%NNrc)rvrOrPrwrGrTrrrrrrrrpropertyrrrr$r%r&rrsu$><   ($( !!r%rc eZdZy)rN)rvrOrPr$r%r&rrAsr%rrXc|tzSrc)_counter) name_templates r&_newnamerGs 8: %%r%ctDcgc]}|jr|}}tj|ycc}w)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. N)_shutdown_locksrIdifference_update)r to_removes r&_maintain_shutdown_locksrYs4#2G/$/IG%%i0Hs;;c&eZdZdZdZ ddddZdZdZdZd Z d Z d Z e rd Z d ZdZdZdZddZd dZedZej,dZedZe redZdZedZej,dZdZdZdZdZy)!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. FN)daemonc|i}|r t|}n#td}| |j}|d|dz }||_||_||_||_||rts td||_ ntj|_ d|_ trd|_d|_t#|_d|_d|_t*j,|_t1|_t4j7|y#t$rYwxYw)aUThis 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 a list or tuple of arguments 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 ()z4daemon threads are disabled in this (sub)interpreterFT)strrrvAttributeError_target_name_args_kwargs_daemon_threads_allowedr` _daemonicr r_ident_HAVE_THREAD_NATIVE_ID _native_id _tstate_lockr_started _is_stopped _initializedr/stderr_stderr_make_invoke_excepthook_invoke_excepthook _danglingadd)rFgrouptargetrLr;r<r target_names r&rGzThread.__init__ts0 >F t9DK(D!"(//Kb Q//D     57"#YZZ#DN+-44DN !"DO    {{ "9"; d1&sC>> D  D c|jj|rB|j5|jj|jjyyd|_d|_yr#)rrVrrYr)rFis_alives r&_reset_internal_lockszThread._reset_internal_lockss` %%'   ,!!113!!))+- $D  $D r%c,d}|jjrd}|j|jrd}|jr|dz }|j |d|j zz }d|j jd|jd|d S) Ninitialstartedstoppedz daemonz %sr(z, z)>) rrr#rrrrNrvr )rFrs r&rTzThread.__repr__s} ==   !F    F >> i F ;; " edkk) )F!%!8!8$**fMMr%c|js td|jjr tdt5|t |<ddd t |jd|jjy#1swY;xYw#t$r$t5t |=ddd#1swYxYwwxYw)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$) rr`rr_active_limbo_lock_limbo_start_new_thread _bootstrap ExceptionrrEs r&startz Thread.starts  => > ==   !AB B F4L   door 2   #4L$ $  s0 BBBC"B3* C3B< 8Cc |j&|j|ji|j|`|`|`y#|`|`|`wxYw)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 rrrEs r&runz Thread.runsI 7||' djj9DLL9 dj$, dj$,s 2;AcZ |jy#|jrtYyxYwrc)_bootstrap_innerrr/rEs r&r.zThread._bootstraps+   ! ! # ~~$, s **c"t|_yrc)rrrEs r& _set_identzThread._set_idents k r%c"t|_yrc)r(rrEs r&_set_native_idzThread._set_native_ids +oDOr%ct|_|jj|js9t5t t j|jdddyy#1swYyxYw)z Set a lock object which will be released by the interpreter when the underlying thread state (see pystate.h) gets deleted. N) _set_sentinelrrYr_shutdown_locks_lockrrrrEs r&_set_tstate_lockzThread._set_tstate_locksX *O !!#{{%(*##D$5$56&%%%s *A00A9c( |j|jtr|j|jj t 5|t|j<t|=dddtrtjttrtjt |j|j#y#1swYixYw#|j!|Y2xYw#|j#wxYwrc)r6r<rr8rrr+rKrr,r4r/rr+rr2r_deleterEs r&r4zThread._bootstrap_inner"s  OO   ! ! #%##% MM   #'+ $4L$ k* . .  LLN$# .''- LLNs7AC?C3AC?:C'C$ C?'C<:C??Dc|j}|d|_d|_|jst5t dddyyy#1swYyxYwr#)rrrr;rrs r&_stopz Thread._stop9sJ"     {{%(*&%%%s AAcXt5tt=dddy#1swYyxYw)zARemove current thread from the dict of currently running threads.N)r+rKrrEs r&r>zThread._deleteTs  $  s )c|js td|jjs td|t ur td||j y|j t |dy)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)r[)rr`rrr _wait_for_tstate_lockmaxrs r&joinz Thread.join]sv0  => >}}##%HI I ># #;< < ?  & & (  & &s7A & ?r%c|j}|y |j||r!|j|jyy#|j r |j|jxYwrc)rrYrar@rI)rFblockr[rs r&rDzThread._wait_for_tstate_locksj   <  ||E7+  , {{}   s 2A3A8c|jS)zA 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 rEs r&rLz Thread.nameszzr%c$t||_yrc)r r )rFrLs r&rLz Thread.namesY r%c|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. )rrEs r&identz Thread.idents{{r%c|jS)zNative 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. )rrEs r& native_idzThread.native_ids?? "r%c|js|jjsy|jd|j S)zReturn 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)rrrrDrEs r&r#zThread.is_alives<   4==#7#7#9 ""5)####r%c|jS)aA 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. )rrEs r&rz Thread.daemons~~r%c|js td|rts td|jj r td||_y)NrCz/daemon threads are disabled in this interpreterz)cannot set daemon status of active thread)rr`rrrr)rFdaemonics r&rz Thread.daemonsO  => > 35PQ Q ==   !JK K!r%cRddl}|jdtd|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 insteadrrrrrrrs r&isDaemonzThread.isDaemons*  R(Q  8{{r%cJddl}|jdtd||_y)ztSet whether this thread is a daemon. This method is deprecated, use the .daemon property instead. rNz;setDaemon() is deprecated, set the daemon attribute insteadrrrT)rFrRrs r& setDaemonzThread.setDaemons'  S(Q  8 r%cRddl}|jdtd|jS)zReturn a string used for identification purposes only. This method is deprecated, use the name attribute instead. rNz7getName() is deprecated, get the name attribute insteadrrrrrrLrs r&getNamezThread.getNames*  O(Q  8yyr%cJddl}|jdtd||_y)zrSet the name string for this thread. This method is deprecated, use the name attribute instead. rNz7setName() is deprecated, set the name attribute insteadrrrY)rFrLrs r&setNamezThread.setNames'  O(Q  8 r%)NNNr$Nrcrt)rvrOrPrwrrGr$rTr0r2r.r6rr8r<r4r@r>rFrDrrLsetterrLrNr#rrUrWrZr\r$r%r&rrisL59!%:15:x%" N47"(" . 7.+6%$@L6 [[    #  # $   ]]""    r%r) _excepthook_ExceptHookArgs)print_exception) namedtuplerz'exc_type exc_value exc_traceback threadct|Src)r_)r;s r&rr&s %%r%c|jtk(ryt!tjtj}n&|j|jj }|yy|j|jj }n t}td|d|dt|j|j|j||jy)z9 Handle uncaught Thread.run() exception. NzException in thread :Tfileflush)rf) exc_type SystemExitr/rthreadrrLrprint_print_exception exc_value exc_tracebackrg)r;rrLs r&rr)s ==J &    7[[F [[ $[[((F~  ;; ";;##D;D $TF!, '8J8J$ & r%cttj td tdtjttfd}|S)Nzthreading.excepthook is Nonezsys.excepthook is NonecX t}|}tg |}||d}y#t$rm}d|_~j j}n |j }d|dj j}n }| Yd}~d}yd}~wwxYw#d}wxYw)NTz"Exception in threading.excepthook:re)rrr/__suppress_context__rr) rjhookr;excrsys_excepthook local_print local_sysold_excepthookold_sys_excepthook sys_exc_infos r&invoke_excepthookz2_make_invoke_excepthook..invoke_excepthook\s D|%!";LN";F";    !    ! #'GDKK   s /B  BN)rvrOrPrGr$r%r&rrs(r%rc&eZdZdZdZdZddZy) _DummyThreadc2tj|tdt|jj |j tr|jt5|t|j<dddy#1swYyxYw)NzDummy-%dr) rrGrrrrr6rr8r+rKrrEs r&rGz_DummyThread.__init__sh8J#768  :   !    ! #'GDKK   s 0B  Bcyrcr$rEs r&r@z_DummyThread._stops r%cyr#r$rEs r&r#z_DummyThread.is_alivesr%Ncyrcr$rs r&rFz_DummyThread.joinsr%rc)rvrOrPrGr@r#rFr$r%r&rrs( 3r%rcX ttS#t$r tcYSwxYw)zReturn 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. )rKrrMrr$r%r&r r s+y{## ~s ))cNddl}|jdtdtS)zReturn 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() insteadrr)rrrr rs r& currentThreadrs)  MMO$4  r%cxt5ttttzcdddS#1swYyxYw)zReturn the number of Thread objects currently alive. The returned count is equal to the length of the list returned by enumerate(). N)r+rrKr,r$r%r&rrs( 7|c&k)**  s09cNddl}|jdtdtS)zxReturn the number of Thread objects currently alive. This function is deprecated, use active_count() instead. rNz7activeCount() is deprecated, use active_count() insteadrr)rrrrrs r& activeCountrs(  MMK$4 >r%cxttjttjzSrc)listrKvaluesr,r$r%r& _enumeraters$  !D$9 99r%ct5ttjttjzcdddS#1swYyxYw)zReturn 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+rrKrr,r$r%r&r r s7 GNN$%V]]_(==>>  s ;A  Actr tdtj|g|i|}tj |y)aCPython 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_DOWNr` functoolspartial_threading_atexitsr)r-argr<calls r&_register_atexitrs;ABB   T 2C 26 2Dd#r%)rctjr trydat t D] }| tj tk(r5tj}|jtjn t5tt}tjdddsy|D]"}|j|j$]#1swY4xYw)zS Wait until the Python thread state of all non-daemon threads get deleted. NT) _main_threadrr'rreversedrrLrrrar@r;rrrrY) atexit_calltlocklocksrs r& _shutdownr's$8$:N 23  4Y[())     !)E  ! ! #" D LLN LLN  ! !s $C((C1ctS)zReturn 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 _s  r%)_local)rctai} tt}|atata t5tt}|jt|D]}||ura|jdt}t|t r)t |_d|_d|_|j)||_|||<h|jd|j-t.j1tj1tj|dddy#t$rt }Y.wxYw#1swYyxYw)zL Cleanup threading module state that should not exist after a fork. TrFN)rr+rKrrMrrrAr;rrrupdaterr$ isinstancerrNr rr<rr@r,r) new_activecurrentthreadsrjrLs r& _after_forkrqs'J )+&L*+eO jl#y!F ,,T2! fl3'2F$#/FL',F$++- % $* 5!,,U3 %(   z"7    -    sD7C3E7E EEregister_at_fork)after_in_child)erwos_ossysr/_threadrtimerr _weakrefsetr itertoolsrrD _collectionsrr} ImportError collections__all__start_new_threadr-daemon_threads_allowedr allocate_lockrAr:rr'r r(rrerrorrrr9r r+r4rr rrr!rrr>r:r rrrrr`r__next__rrr+rKr,rr;rrrrr^rr_r tracebackr`rlra__excepthook__rrrrr rrrrr rrrrrrr rr_threading_localrr|rr$r%r&rsA#%,, <,,!88&&%%     "77#))M! NN?#mm mmG!!    %#  ${{z qqhTTn*!y*!ZOOz`!`!F  !9  &W   I &'% 1 nnb +<\0jF< (& (*3632   * : >$" } 2p'' 7!t 3"#C 4$}4,++,:   #"# G|&(=& 13O&(` '&'skG-- G?:H& H'H*I- G<;G<?H  H HHH'&H'* I  I  II