edP`SrSrSSKrSSKrSSKJr SSKJr "SS5r"S S \\R5r "S S \R5r "S S\\R5r "SS\\R5r "SS\ 5r "SS\R5r"SS\R5rg)zSynchronization primitives.)LockEvent Condition SemaphoreBoundedSemaphoreBarrierN) exceptions)mixinsc \rSrSrSrSrSrg)_ContextManagerMixin c@# UR5IShvN gN7fN)acquireselfs 3/opt/imh/python3.13/lib/python3.13/asyncio/locks.py __aenter___ContextManagerMixin.__aenter__ slln s c,# UR5 g7fr)release)rexc_typeexctbs r __aexit___ContextManagerMixin.__aexit__s sN)__name__ __module__ __qualname____firstlineno__rr__static_attributes__rrr r s  r$r cJ^\rSrSrSrSrU4SjrSrSrSr Sr S r U=r $) raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular task when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another task changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one task is blocked in acquire() waiting for the state to turn to unlocked, only one task proceeds when a release() call resets the state to unlocked; successive release() calls will unblock tasks in FIFO order. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... c SUlSUlgNF)_waiters_lockedrs r__init__ Lock.__init__Ks  r$c>[TU]5nUR(aSOSnUR(aUS[ UR53nSUSSSUS3$ Nlockedunlocked , waiters:)super__repr__r*r)lenrresextra __class__s rr7 Lock.__repr__OsYg  LLj ==gZDMM(:';Lock.acquire..cs9=aKKMM=sT) r*r)all collectionsdeque _get_loop create_futureappendremover CancelledError_wake_up_firstrfuts rr Lock.acquireZs $--"794==999DL == '--/DMnn,,. S!  *  $$S)  $$S)((  <<##%  sBB(D5,C1C2C6C;D5CC88C;;7D22D5cjUR(aSUlUR5 g[S5e)aRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other tasks are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r*rQ RuntimeErrorrs rr Lock.releases* << DL    !67 7r$cUR(dg[[UR55nUR 5(dUR S5 gg![a gf=f)z*Ensure that the first waiter will wake up.NT)r)nextiter StopIterationdone set_resultrRs rrQLock._wake_up_firstsV}}  tDMM*+C xxzz NN4     sA A'&A')r*r)) rr r!r"__doc__r+r7r/rrrQr# __classcell__r<s@rrrs-1f*#J8" ! !r$rcJ^\rSrSrSrSrU4SjrSrSrSr Sr S r U=r $) raAsynchronous equivalent to threading.Event. Class implementing event objects. An event manages 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. cF[R"5UlSUlgr()rJrKr)_valuers rr+Event.__init__s#))+  r$c>[TU]5nUR(aSOSnUR(aUS[ UR53nSUSSSUS3$) Nsetunsetr1r2r r3r4r5)r6r7rer)r8r9s rr7Event.__repr__sYg ' ==gZDMM(:';[TU]5nUR5(aSOSnUR(aUS[ UR53nSUSSSUS3$r.)r6r7r/r)r8r9s rr7Condition.__repr__s]g  KKMMz ==gZDMM(:';D /C)4B95C):D EB=,B;-B=1E6C"8E>9C);B==CCECE"C&&E)DD ED(!D$"D('E(E<E>EEEEEEEE;;E>c~# U"5nU(d(UR5IShvN U"5nU(dM(U$N7f)zWait until a predicate becomes true. The predicate should be a callable whose result will be interpreted as a boolean value. The method will repeatedly wait() until it evaluates to true. The final predicate value is the return value. Nru)r predicateresults rwait_forCondition.wait_for/s:))+  [F&  s"=;==cfUR5(d [S5eURU5 g)aBy default, wake up one task waiting on this condition, if any. If the calling task has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up n of the tasks waiting for the condition variable; if fewer than n are waiting, they are all awoken. Note: an awakened task does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockN)r/rVr)rns rnotifyCondition.notify=s&{{}}BC C Qr$cSnURH7nX!:a gUR5(aM!US- nURS5 M9 g)Nrr F)r)r\r])rridxrSs rrCondition._notifyMs===Cx88::qu% !r$cLUR[UR55 g)zWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rr8r)rs r notify_allCondition.notify_allWs C &'r$)r{r)rr/rrr )rr r!r"r_r+r7rurrrrr#r`ras@rrrs1 ,*5n  &((r$rcN^\rSrSrSrS SjrU4SjrSrSrSr Sr S r U=r $) ri`aA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. c@US:a [S5eSUlXlg)Nrz$Semaphore initial value must be >= 0) ValueErrorr)re)rvalues rr+Semaphore.__init__os! 19CD D  r$c>[TU]5nUR5(aSOSUR3nUR(aUS[ UR53nSUSSSUS3$) Nr/zunlocked, value:r1r2r r3r4r5)r6r7r/rer)r8r9s rr7Semaphore.__repr__usig  KKMM1A$++/O ==gZDMM(:';.sA,?aKKM!!,?s!#r)reanyr)rs rr/Semaphore.locked|s6{{aC ADMM,?R,?A A Cr$cT# UR5(dU=RS-slgURc[R"5UlUR 5R 5nURRU5 UIShvN URRU5 URS:a)UR5(dgURS:aM)gNZ!URRU5 f=f![RaA UR5(a*UR5(dU=RS- slef=f!URS:a)UR5(dfURS:aM(ff=f7f)aAcquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other task has called release() to make it larger than 0, and then return True. r TNr)r/rer)rJrKrLrMrNrOr rPr\rC _wake_up_nextrRs rrSemaphore.acquires<{{}} KK1 K == '--/DMnn,,. S!  *  $$S)++/))++++/' $$S)(( xxzz#--//  q  ++/))++++/s[B F(C2C0C2D67F(/F(0C22DDAE''E**7F%#F%%F(cNU=RS- slUR5 g)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another task is waiting for it to become larger than zero again, wake up that task. r N)rerrs rrSemaphore.releases q  r$cUR(dgURH@nUR5(aMU=RS-slURS5 g g)z)Wake up the first waiter that isn't done.Fr T)r)r\rer]rRs rrSemaphore._wake_up_nextsG}}==C88:: q t$ ! r$rwr) rr r!r"r_r+r7r/rrrr#r`ras@rrr`s-  *C (T  r$rc<^\rSrSrSrSU4SjjrU4SjrSrU=r$)rizA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. c0>Xl[TU] U5 gr) _bound_valuer6r+)rrr<s rr+BoundedSemaphore.__init__s! r$cl>URUR:a [S5e[TU]5 g)Nz(BoundedSemaphore released too many times)rerrr6r)rr<s rrBoundedSemaphore.releases+ ;;$++ +GH H r$)rr) rr r!r"r_r+rr#r`ras@rrrs  r$rc$\rSrSrSrSrSrSrSrg) _BarrierStateifillingdraining resettingbrokenrN) rr r!r"FILLINGDRAINING RESETTINGBROKENr#rr$rrrsGHI Fr$rc^\rSrSrSrSrU4SjrSrSrSr Sr S r S r S r S rS r\S5r\S5r\S5rSrU=r$)rizAsyncio equivalent to threading.Barrier Implements a Barrier primitive. Useful for synchronizing a fixed number of tasks at known synchronization points. Tasks block on 'wait()' and are simultaneously awoken once they have all made their call. cUS:a [S5e[5UlXl[R UlSUlg)z1Create a barrier, initialised to 'parties' tasks.r zparties must be >= 1rN)rr_cond_partiesrr_state_count)rpartiess rr+Barrier.__init__s7 Q;34 4[  #++  r$c>[TU]5nURRnUR(dUSUR SUR 3- nSUSSSUS3$)Nr1/r2r r3r4r5)r6r7rrr n_waitingrr9s rr7Barrier.__repr__sdg ;;$$%{{ z$..!14<<.A AE3q9+Rwb))r$c># UR5IShvN $N7frrrs rrBarrier.__aenter__sYY[   s c # g7frr)rargss rrBarrier.__aexit__s sc<# URIShvN UR5IShvN URnU=RS- slUS-UR:XaUR 5IShvN OUR 5IShvN UU=RS-slUR 5 sSSS5IShvN $NNNYNBN !U=RS-slUR 5 f=f!,IShvN (df  g=f7f)zWait for the barrier. When the specified number of tasks have started waiting, they are all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'. Nr )r_blockrr_release_wait_exit)rindexs rru Barrier.waits:::++-     q 19 ---/))**,&& q  ::  *& q  ::sDCDDCDAC8C9CCC%D< DC DDCCD'C??DDD DDc^# TRRU4Sj5IShvN TR[RLa[ R "S5egN87f)Nc^>TR[R[R4;$r)rrrrrsr Barrier._block..s$DKK&& (?(?(r$zBarrier aborted)rrrrrr BrokenBarrierErrorrs`rrBarrier._blocksY jj!!     ;;-.. .//0AB B / s#A!A9A!cj# [RUlURR 5 g7fr)rrrrrrs rrBarrier._release&s$ $,,  s13c^# TRRU4Sj5IShvN TR[R[R 4;a[ R"S5egNI7f)Nc<>TR[RL$r)rrrrsrrBarrier._wait..4s$++]=R=R*Rr$zAbort or reset of barrier)rrrrrrr rrs`rr Barrier._wait.s\ jj!!"RSSS ;;=//1H1HI I//0KL L J Ts#A2A0A A2cURS:Xa^UR[R[R4;a[R UlUR R5 gg)Nr)rrrrrrrrrs rr Barrier._exit9sO ;;! {{}66 8N8NOO+33 JJ ! ! # r$cv# URIShvN URS:a3UR[RLa[RUlO[R UlURR 5 SSS5IShvN gNN!,IShvN (df  g=f7f)zrReset the barrier to the initial state. Any tasks currently waiting will get the BrokenBarrier exception raised. Nr)rrrrrrrrs rreset Barrier.resetAsg :::{{Q;;m&=&=="/"9"9DK+33 JJ ! ! #:::::sEB9BB9A3B B9BB9B9B6%B( & B62B9c# URIShvN [RUlURR 5 SSS5IShvN gNDN!,IShvN (df  g=f7f)zPlace the barrier into a 'broken' state. Useful in case of error. Any currently waiting tasks and tasks attempting to 'wait()' will have BrokenBarrierError raised. N)rrrrrrs rabort Barrier.abortPs< :::'..DK JJ ! ! #:::::sDA6AA60A A6AA6A6A3"A% # A3/A6cUR$)z8Return the number of tasks required to trip the barrier.)rrs rrBarrier.partiesZs}}r$cVUR[RLa UR$g)zrs! * D! !7!7D!N:&F " ":&zB($f&<&<B(J`$f&<&<`Fy$DIIM3f$$M3r$