/usr/lib/python3.10/__pycache__
NameSizeModeActions
abc.cpython-310.pyc67510644editdlrm
aifc.cpython-310.pyc246850644editdlrm
antigravity.cpython-310.pyc8220644editdlrm
argparse.cpython-310.pyc635390644editdlrm
ast.cpython-310.pyc557390644editdlrm
asynchat.cpython-310.pyc70250644editdlrm
asyncore.cpython-310.pyc160020644editdlrm
base64.cpython-310.pyc171620644editdlrm
bdb.cpython-310.pyc258320644editdlrm
binhex.cpython-310.pyc128700644editdlrm
bisect.cpython-310.pyc25880644editdlrm
bz2.cpython-310.pyc108700644editdlrm
calendar.cpython-310.pyc263030644editdlrm
cgi.cpython-310.pyc267230644editdlrm
cgitb.cpython-310.pyc99980644editdlrm
chunk.cpython-310.pyc48600644editdlrm
cmd.cpython-310.pyc127070644editdlrm
code.cpython-310.pyc99570644editdlrm
codecs.cpython-310.pyc332190644editdlrm
codeop.cpython-310.pyc55950644editdlrm
colorsys.cpython-310.pyc32650644editdlrm
compileall.cpython-310.pyc127330644editdlrm
configparser.cpython-310.pyc454580644editdlrm
contextlib.cpython-310.pyc208950644editdlrm
contextvars.cpython-310.pyc2460644editdlrm
copy.cpython-310.pyc69960644editdlrm
copyreg.cpython-310.pyc46830644editdlrm
cProfile.cpython-310.pyc51130644editdlrm
crypt.cpython-310.pyc35500644editdlrm
csv.cpython-310.pyc117980644editdlrm
dataclasses.cpython-310.pyc265780644editdlrm
datetime.cpython-310.pyc565330644editdlrm
decimal.cpython-310.pyc3620644editdlrm
difflib.cpython-310.pyc589050644editdlrm
dis.cpython-310.pyc156560644editdlrm
doctest.cpython-310.pyc761750644editdlrm
enum.cpython-310.pyc260630644editdlrm
filecmp.cpython-310.pyc87490644editdlrm
fileinput.cpython-310.pyc140720644editdlrm
fnmatch.cpython-310.pyc42440644editdlrm
fractions.cpython-310.pyc186000644editdlrm
ftplib.cpython-310.pyc290340644editdlrm
functools.cpython-310.pyc283350644editdlrm
genericpath.cpython-310.pyc39070644editdlrm
getopt.cpython-310.pyc63390644editdlrm
getpass.cpython-310.pyc42100644editdlrm
gettext.cpython-310.pyc182210644editdlrm
glob.cpython-310.pyc58520644editdlrm
graphlib.cpython-310.pyc76160644editdlrm
gzip.cpython-310.pyc185460644editdlrm
hashlib.cpython-310.pyc68450644editdlrm
heapq.cpython-310.pyc138650644editdlrm
hmac.cpython-310.pyc69730644editdlrm
imaplib.cpython-310.pyc423120644editdlrm
imghdr.cpython-310.pyc39050644editdlrm
imp.cpython-310.pyc97860644editdlrm
inspect.cpython-310.pyc851530644editdlrm
io.cpython-310.pyc36630644editdlrm
ipaddress.cpython-310.pyc626700644editdlrm
keyword.cpython-310.pyc9270644editdlrm
linecache.cpython-310.pyc41420644editdlrm
locale.cpython-310.pyc461540644editdlrm
lzma.cpython-310.pyc121000644editdlrm
mailbox.cpython-310.pyc600910644editdlrm
mailcap.cpython-310.pyc73200644editdlrm
mimetypes.cpython-310.pyc176190644editdlrm
modulefinder.cpython-310.pyc161660644editdlrm
netrc.cpython-310.pyc39330644editdlrm
nntplib.cpython-310.pyc316230644editdlrm
ntpath.cpython-310.pyc147040644editdlrm
nturl2path.cpython-310.pyc17470644editdlrm
numbers.cpython-310.pyc118660644editdlrm
opcode.cpython-310.pyc54470644editdlrm
operator.cpython-310.pyc135080644editdlrm
optparse.cpython-310.pyc477540644editdlrm
os.cpython-310.pyc315990644editdlrm
pathlib.cpython-310.pyc420520644editdlrm
pdb.cpython-310.pyc474400644editdlrm
pickle.cpython-310.pyc468820644editdlrm
pickletools.cpython-310.pyc677600644editdlrm
pipes.cpython-310.pyc77690644editdlrm
pkgutil.cpython-310.pyc183610644editdlrm
platform.cpython-310.pyc274290644editdlrm
plistlib.cpython-310.pyc237650644editdlrm
poplib.cpython-310.pyc135730644editdlrm
posixpath.cpython-310.pyc105600644editdlrm
pprint.cpython-310.pyc178750644editdlrm
profile.cpython-310.pyc143910644editdlrm
pstats.cpython-310.pyc236210644editdlrm
pty.cpython-310.pyc41430644editdlrm
pyclbr.cpython-310.pyc97750644editdlrm
pydoc.cpython-310.pyc856450644editdlrm
py_compile.cpython-310.pyc73390644editdlrm
queue.cpython-310.pyc107920644editdlrm
quopri.cpython-310.pyc57940644editdlrm
random.cpython-310.pyc227480644editdlrm
re.cpython-310.pyc142270644editdlrm
reprlib.cpython-310.pyc52500644editdlrm
rlcompleter.cpython-310.pyc59540644editdlrm
runpy.cpython-310.pyc94110644editdlrm
sched.cpython-310.pyc61150644editdlrm
secrets.cpython-310.pyc21750644editdlrm
selectors.cpython-310.pyc171050644editdlrm
shelve.cpython-310.pyc94920644editdlrm
shlex.cpython-310.pyc77820644editdlrm
shutil.cpython-310.pyc385360644editdlrm
signal.cpython-310.pyc29350644editdlrm
site.cpython-310.pyc179220644editdlrm
sitecustomize.cpython-310.pyc2250644editdlrm
smtpd.cpython-310.pyc261470644editdlrm
smtplib.cpython-310.pyc357660644editdlrm
sndhdr.cpython-310.pyc69620644editdlrm
socket.cpython-310.pyc289630644editdlrm
socketserver.cpython-310.pyc253470644editdlrm
sre_compile.cpython-310.pyc151940644editdlrm
sre_constants.cpython-310.pyc63570644editdlrm
sre_parse.cpython-310.pyc217550644editdlrm
ssl.cpython-310.pyc452710644editdlrm
stat.cpython-310.pyc42730644editdlrm
statistics.cpython-310.pyc370510644editdlrm
string.cpython-310.pyc71020644editdlrm
stringprep.cpython-310.pyc170750644editdlrm
struct.cpython-310.pyc3070644editdlrm
subprocess.cpython-310.pyc447410644editdlrm
sunau.cpython-310.pyc164820644editdlrm
symtable.cpython-310.pyc128350644editdlrm
sysconfig.cpython-310.pyc181510644editdlrm
tabnanny.cpython-310.pyc69500644editdlrm
tarfile.cpython-310.pyc715780644editdlrm
telnetlib.cpython-310.pyc185060644editdlrm
tempfile.cpython-310.pyc273390644editdlrm
textwrap.cpython-310.pyc138120644editdlrm
this.cpython-310.pyc12640644editdlrm
threading.cpython-310.pyc449690644editdlrm
timeit.cpython-310.pyc117690644editdlrm
token.cpython-310.pyc27380644editdlrm
tokenize.cpython-310.pyc171940644editdlrm
trace.cpython-310.pyc198700644editdlrm
traceback.cpython-310.pyc217120644editdlrm
tracemalloc.cpython-310.pyc175250644editdlrm
tty.cpython-310.pyc10790644editdlrm
turtle.cpython-310.pyc1288570644editdlrm
types.cpython-310.pyc95250644editdlrm
typing.cpython-310.pyc852770644editdlrm
uu.cpython-310.pyc38670644editdlrm
uuid.cpython-310.pyc224980644editdlrm
warnings.cpython-310.pyc136460644editdlrm
wave.cpython-310.pyc175940644editdlrm
weakref.cpython-310.pyc203430644editdlrm
webbrowser.cpython-310.pyc174630644editdlrm
xdrlib.cpython-310.pyc78800644editdlrm
zipapp.cpython-310.pyc60130644editdlrm
zipfile.cpython-310.pyc618450644editdlrm
zipimport.cpython-310.pyc170330644editdlrm
_aix_support.cpython-310.pyc28790644editdlrm
_bootsubprocess.cpython-310.pyc22940644editdlrm
_collections_abc.cpython-310.pyc329250644editdlrm
_compat_pickle.cpython-310.pyc58720644editdlrm
_compression.cpython-310.pyc45120644editdlrm
_distutils_system_mod.cpython-310.pyc54220644editdlrm
_markupbase.cpython-310.pyc75720644editdlrm
_osx_support.cpython-310.pyc115350644editdlrm
_pydecimal.cpython-310.pyc1577360644editdlrm
_pyio.cpython-310.pyc736540644editdlrm
_py_abc.cpython-310.pyc46830644editdlrm
_sitebuiltins.cpython-310.pyc35470644editdlrm
_strptime.cpython-310.pyc159450644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-310.pyc353850644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-310.pyc353790644editdlrm
_threading_local.cpython-310.pyc65390644editdlrm
_weakrefset.cpython-310.pyc76080644editdlrm
__future__.cpython-310.pyc41310644editdlrm
__phello__.foo.cpython-310.pyc1300644editdlrm
Edit: /usr/lib/python3.10/__pycache__/threading.cpython-310.pyc (44969B)
o 9jp@s6dZddlZddlZddlZddlZddlmZ ddl m Z ddl m ZmZzddlmZWney=ddlmZYnwgdZejZejZejZejZz ejZdZed Wn e yed ZYnwej!Z"zej#Z$Wn e yydZ$Ynwej%Z%[da&da'd d Z(d dZ)ddZ*ddZ+eZ,ddZ#GdddZ-e-Z.GdddZ/GdddZ0Gddde0Z1GdddZ2Gdd d Z3Gd!d"d"e4Z5ed#j6Z7d$d%Z8e#a9iZ:iZ;e Za?d&d'Z@Gd(d)d)ZAz dd*lmBaCmDZEWn#eydd+lFmGZHdd,lmIZIeId-d.ZDd/d-ZEd0d1aCYnwtCZJd2d3ZKGd4d5d5eAZLGd6d7d7eAZMGd8d9d9eAZNd:d;ZOdd?ZQd@dAZRdBdCZSdDdEZTgZUd aVdFdGZWddHlmXZXeMaYdIdJZZdKdLZ[zddMlm\Z]WneyddNl^m]Z]YnwdOdPZ_e`edQrejae_dRdSdS)Sz;Thread module emulating a subset of Java's threading model.N) monotonic)WeakSet)islicecount)deque) get_ident active_count Conditioncurrent_thread enumerate main_thread TIMEOUT_MAXEventLockRLock SemaphoreBoundedSemaphoreThreadBarrierBrokenBarrierErrorTimer ThreadError setprofilesettracelocal stack_size excepthookExceptHookArgsgettrace getprofileT get_native_idFcC|adS)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_hookfuncr& /usr/lib/python3.10/threading.pyr:rcCtS)z;Get the profiler function as set by threading.setprofile().r"r&r&r&r'rDrcCr!)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$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)argskwargsr&r&r'rZs rc@s^eZdZdZddZddZddZdd d ZeZd d Z ddZ ddZ ddZ ddZ 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|_dSNr)_allocate_lock_block_owner_countselfr&r&r'__init__qs z_RLock.__init__c Cs\|j}zt|j}Wn tyYnwd|jrdnd|jj|jj||j t t |fS)Nz)<%s %s.%s object owner=%r count=%d at %s>lockedunlocked) r5_activenameKeyErrorr4r: __class__ __module__ __qualname__r6hexid)r8ownerr&r&r'__repr__vs  z_RLock.__repr__cCs|jd|_d|_dSr2)r4_at_fork_reinitr5r6r7r&r&r'rFs  z_RLock._at_fork_reinitTcCsDt}|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. )rr5r6r4acquire)r8blockingtimeoutmercr&r&r'rIs z_RLock.acquirecCs@|jtkr td|jd|_}|sd|_|jdSdS)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 lockrHN)r5r RuntimeErrorr6r4release)r8rr&r&r'rPs z_RLock.releasecC |dSNrPr8tvtbr&r&r'__exit__ z_RLock.__exit__cCs|j|\|_|_dSrR)r4rIr6r5)r8stater&r&r'_acquire_restores z_RLock._acquire_restorecCs<|jdkr td|j}d|_|j}d|_|j||fS)NrrN)r6rOr5r4rP)r8rrDr&r&r' _release_saves  z_RLock._release_savecCs |jtkSrR)r5rr7r&r&r' _is_ownedrYz_RLock._is_ownedNTrG)__name__r@rA__doc__r9rErFrI __enter__rPrXr[r\r]r&r&r&r'r1gs  $ r1c@seZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ dddZ dddZ dddZddZddZdS) 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|_ dSrR) r_lockrIrPr\AttributeErrorr[r]_deque_waitersr8lockr&r&r'r9s*       zCondition.__init__cCs|j|jdSrR)rbrFreclearr7r&r&r'rFs zCondition._at_fork_reinitcCs |jSrR)rbrar7r&r&r'ra zCondition.__enter__cGs |jj|SrR)rbrX)r8r/r&r&r'rX rYzCondition.__exit__cCsd|jt|jfS)Nz)rblenrer7r&r&r'rEszCondition.__repr__cC|jdSrR)rbrPr7r&r&r'r\zCondition._release_savecCrkrR)rbrI)r8xr&r&r'r[rlzCondition._acquire_restorecCs|jdr |jdSdS)NFT)rbrIrPr7r&r&r'r]s  zCondition._is_ownedcCs|stdt}||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]rOr3rIreappendr\r[remove ValueError)r8rKwaiter saved_stategotitr&r&r'wait s>      zCondition.waitcCs^d}|}|}|s-|dur#|durt|}n |t}|dkr# |S|||}|r |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)_timert)r8 predicaterKendtimewaittimeresultr&r&r'wait_forPs    zCondition.wait_forrHcCs|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 lockrrHN)r]rOrerProrp)r8nwaitersrqr&r&r'notifygs"     zCondition.notifycCs|t|jdS)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)r}rjrer7r&r&r' notify_allszCondition.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)warningswarnDeprecationWarningr~r8rr&r&r' notifyAlls  zCondition.notifyAllrRrH)r_r@rAr`r9rFrarXrEr\r[r]rtrzr}r~rr&r&r&r'r s  0  r c@s:eZdZdZd ddZdddZeZd 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. rHcCs&|dkrtdtt|_||_dS)Nrz$semaphore initial value must be >= 0)rpr r_cond_valuer8valuer&r&r'r9s  zSemaphore.__init__TNcCs|s |dur tdd}d}|jM|jdkr=|sn4|dur2|dur(t|}n |t}|dkr2n$|j||jdks|jd8_d}Wd|SWd|SWd|S1sawY|S)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 acquireFrrHT)rprrrurt)r8rJrKrMrwr&r&r'rIs8          zSemaphore.acquirecCsb|dkrtd|j|j|7_t|D]}|jqWddS1s*wYdS)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. rHn must be one or moreN)rprrranger}r8r{ir&r&r'rPs  "zSemaphore.releasecCrQrRrSrTr&r&r'rXrYzSemaphore.__exit__r)TN) r_r@rAr`r9rIrarPrXr&r&r&r'rs -  rc@s$eZdZdZdddZdddZdS) 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. rHcCst||||_dSrR)rr9_initial_valuerr&r&r'r9  zBoundedSemaphore.__init__cCsz|dkrtd|j(|j||jkrtd|j|7_t|D]}|jq#WddS1s6wYdS)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. rHrz!Semaphore released too many timesN)rprrrrr}rr&r&r'rPs   "zBoundedSemaphore.releaseNr)r_r@rAr`r9rPr&r&r&r'rs rc@sJeZdZdZddZddZddZdd Zd d Zd d Z dddZ dS)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. cCstt|_d|_dS)NF)r rr_flagr7r&r&r'r9!rzEvent.__init__cCrkrR)rrFr7r&r&r'rF%zEvent._at_fork_reinitcC|jS)z5Return true if and only if the internal flag is true.)rr7r&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() insteadrr)rrrrrr&r&r'isSet-s z Event.isSetcCs<|jd|_|jWddS1swYdS)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)rrr~r7r&r&r'set8s "z Event.setcCs2|j d|_WddS1swYdS)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)rrr7r&r&r'rhCs"z Event.clearNcCsD|j|j}|s|j|}|WdS1swYdS)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)rrrt)r8rKsignaledr&r&r'rtMs  $z Event.waitrR) r_r@rAr`r9rFrrrrhrtr&r&r&r'rs    rc@seZdZdZdddZdddZddZd d Zd d Zd dZ ddZ ddZ ddZ e ddZe ddZe ddZdS)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. 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)r8partiesactionrKr&r&r'r9ws  zBarrier.__init__c Cs|dur|j}|jB||j}|jd7_z&|d|jkr&|n|||W|jd8_|WdS|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'. NrH)rr_enterr6r_release_wait_exit)r8rKindexr&r&r'rts"    z Barrier.waitcCs>|jdvr|j|jdvs|jdkrt|jdksJdS)NrGrHr)rrrtrr7r&r&r'rs   zBarrier._entercCs6z|jr|d|_|jWdS|)NrH)rrrr~_breakr7r&r&r'rszBarrier._releasecsBjfdd|stjdkrtjdksJdS)Ncs jdkSr2rr&r7r&r's zBarrier._wait..rrH)rrzrrrr8rKr&r7r'rs  z Barrier._waitcCs0|jdkr|jdvrd|_|jdSdSdS)Nrr)r6rrr~r7r&r&r'rs  z Barrier._exitcCsj|j(|jdkr|jdkrd|_n |jdkrd|_nd|_|jWddS1s.wYdS)zReset the barrier to the initial state. Any threads currently waiting will get the BrokenBarrier exception raised. rrGN)rr6rr~r7r&r&r'resets    "z Barrier.resetcCs4|j |WddS1swYdS)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)rrr7r&r&r'aborts "z Barrier.abortcCsd|_|jdS)Nr)rrr~r7r&r&r'rszBarrier._breakcCr)z:Return the number of threads required to trip the barrier.)rr7r&r&r'rszBarrier.partiescCs|jdkr|jSdS)z>Return the number of threads currently waiting at the barrier.r)rr6r7r&r&r' n_waitings zBarrier.n_waitingcCs |jdkS)z0Return True if the barrier is in a broken state.rrr7r&r&r'brokens zBarrier.brokenNNrR)r_r@rAr`r9rtrrrrrrrpropertyrrrr&r&r&r'rns"       rc@s eZdZdS)rN)r_r@rAr&r&r&r'rsrrHcCs |tSrR)_counter) name_templater&r&r'_newnamerircCsddtD}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:).0rgr&r&r' *sz,_maintain_shutdown_locks..N)_shutdown_locksdifference_update) to_remover&r&r'_maintain_shutdown_locks s rc@seZdZdZdZ  d8ddddZdd Zd d Zd d ZddZ ddZ ddZ e r0ddZ ddZddZddZddZd9ddZd:d"d#Zed$d%Zejd&d%Zed'd(Ze reed)d*Zd+d,Zed-d.Zejd/d.Zd0d1Zd2d3Zd4d5Zd6d7ZdS);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|d7}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)strrr_rc_target_name_args_kwargs _daemonicr r_ident_HAVE_THREAD_NATIVE_ID _native_id _tstate_lockr_started _is_stopped _initialized_sysstderr_stderr_make_invoke_excepthook_invoke_excepthook _danglingadd)r8grouptargetr=r/r0r target_namer&r&r'r9;s<   zThread.__init__cCsD|j|r|jdur|j|jdSdSd|_d|_dSNT)rrFrrIr)r8is_aliver&r&r'_reset_internal_locksus    zThread._reset_internal_lockscCsl|jsJdd}|jrd}||jrd}|jr |d7}|jdur,|d|j7}d|jj|j |fS)Nz Thread.__init__() was not calledinitialstartedstoppedz daemonz %sz <%s(%s, %s)>) rrrrrrrr?r_r)r8statusr&r&r'rEs  zThread.__repr__c Cs|jstd|jrtdt |t|<Wdn1s!wYzt|jdWntyKt t|=Wd1sEwYw|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&) rrOrr_active_limbo_lock_limbo_start_new_thread _bootstrap Exceptionrtr7r&r&r'starts$     z Thread.startcCsRz!|jdur|j|ji|jW|`|`|`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)rrrr7r&r&r'runs  z Thread.runcCs,z|WdS|jrtdurYdSrR)_bootstrap_innerrrr7r&r&r'rs  zThread._bootstrapcC t|_dSrR)rrr7r&r&r' _set_identrYzThread._set_identcCrrR)r rr7r&r&r'_set_native_idrYzThread._set_native_idcCsXt|_|j|js*ttt|jWddS1s#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_sentinelrrIr_shutdown_locks_lockrrrr7r&r&r'_set_tstate_locks "zThread._set_tstate_lockcCs4zt||tr||jt|t|j<t |=Wdn1s)wYt r5t t t r.invoke_excepthook)rrrOexc_infor )rr&rr'rs rc@s*eZdZdZd ddZddZddZdS) rzCall 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|_dSrR)rr9intervalfunctionr/r0rfinished)r8rrr/r0r&r&r'r9Ss  zTimer.__init__cCs|jdS)z)Stop the timer if it hasn't finished yet.N)rrr7r&r&r'cancel[rz Timer.cancelcCs:|j|j|js|j|ji|j|jdSrR)rrtrrrr/r0rr7r&r&r'r_s z Timer.runr)r_r@rAr`r9rrr&r&r&r'rJs   rc@seZdZddZdS) _MainThreadcCsjtj|ddd||j|tr|t|t |j <WddS1s.wYdS)N MainThreadFr=r) rr9rrrrrrrr<rr7r&r&r'r9js  "z_MainThread.__init__N)r_r@rAr9r&r&r&r'rhs rc@s.eZdZddZddZddZd dd ZdS) _DummyThreadcCsftj|tddd|j|tr|t|t |j <WddS1s,wYdS)NzDummy-%dTr ) rr9rrrrrrrr<rr7r&r&r'r9s  "z_DummyThread.__init__cCsdSrRr&r7r&r&r'rsz_DummyThread._stopcCs|js|js JdSr)rrrr7r&r&r'rsz_DummyThread.is_aliveNcCsJd)NFzcannot join a dummy threadr&rr&r&r'rrz_DummyThread.joinrR)r_r@rAr9rrrr&r&r&r'r!}s  r!cCs&zttWStytYSw)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. )r<rr>r!r&r&r&r'r s    r cCddl}|jdtddtS)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 rr&r&r' currentThreadrr$cCs8tttttWdS1swYdS)zReturn the number of Thread objects currently alive. The returned count is equal to the length of the list returned by enumerate(). N)rrjr<rr&r&r&r'rs$rcCr")zxReturn the number of Thread objects currently alive. This function is deprecated, use active_count() instead. rNz7activeCount() is deprecated, use active_count() insteadrr)rrrrr#r&r&r' activeCountrr%cCsttttSrR)listr<valuesrr&r&r&r' _enumeratesr(cCs@tttttWdS1swYdS)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)rr&r<r'rr&r&r&r'r s$r cOs2trtdtj|g|Ri|}t|dS)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_DOWNrO functoolspartial_threading_atexitsrn)r%argr0callr&r&r'_register_atexits r/)rcCstjrdSdattD]}|q tjtkr/tj}|dus J|s&J| t n t t t }t Wdn1sFwY|sOdS|D] }|| qQq1)zS Wait until the Python thread state of all non-daemon threads get deleted. NT) _main_threadrr)reversedr,rrrr:rPrrr&rrhrI) atexit_calltlocklocksrgr&r&r' _shutdowns.        r5cCr))zReturn the main thread object. In normal conditions, the main thread is the thread from which the Python interpreter was started. )r0r&r&r&r'r &sr )_local)rcCstai}ztt}Wn tyt}Ynw|atat a tJt t }| t |D]}||urF|dt}||_|||<q0|d|q0ttt |ttdkseJWddS1spwYdS)zL Cleanup threading module state that should not exist after a fork. TFrHN)rrr<rr>rr0r3rrrr(updaterrrrrrhrj) new_activecurrentthreadsr rr&r&r' _after_fork7s4         "r;register_at_fork)after_in_child)br`os_ossysr_threadr*timerru _weakrefsetr itertoolsr_islicerr6 _collectionsrrd ImportError collections__all__start_new_threadr allocate_lockr3rrr rrnrcerrorrrr-r r#r,rrrrrr1r.r rrrrrOr__next__rrrr<rrrrrrrrrrr tracebackrr r__excepthook__rrrr!r r$rr%r(r r,r)r/rr0r5r r6r_threading_localr;hasattrr<r&r&r&r's          v;S)X 6   ,5      8  5