python (3.11.7)

(root)/
lib/
python3.11/
asyncio/
__pycache__/
locks.cpython-311.pyc

eFJbdZdZddlZddlZddlmZddlmZddlmZGdd	ZGd
deej	Z
Gdd
ej	ZGddeej	ZGddeej	Z
Gdde
ZGddejZGddej	ZdS)zSynchronization primitives.)LockEvent	Condition	SemaphoreBoundedSemaphoreBarrierN)
exceptions)mixins)tasksceZdZdZdZdS)_ContextManagerMixinc>K|d{VdSN)acquireselfs A/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/asyncio/locks.py
__aenter__z_ContextManagerMixin.__aenter__s-llnntc2K|dSr)release)rexc_typeexctbs    r	__aexit__z_ContextManagerMixin.__aexit__srN)__name__
__module____qualname__rrrrrr
s2rrc@eZdZdZdZfdZdZdZdZdZ	xZ
S)raPrimitive lock objects.

    A primitive lock is a synchronization primitive that is not owned
    by a particular coroutine 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 coroutine 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 coroutine is blocked in acquire() waiting for
    the state to turn to unlocked, only one coroutine proceeds when a
    release() call resets the state to unlocked; first coroutine which
    is blocked in acquire() is being processed.

    acquire() is a coroutine and should be called with 'await'.

    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"d|_d|_dSNF)_waiters_lockedrs r__init__z
Lock.__init__Ns
rct}|jrdnd}|jr|dt	|j}d|ddd|dS	Nlockedunlocked
, waiters:<r	 []>)super__repr__r%r$lenrresextra	__class__s   rr1z
Lock.__repr__Rspgg   L8j=	=<<DM(:(:<<E)3qt9))))))rc|jS)z Return True if lock is acquired.)r%rs rr)zLock.lockedYs
|rc(K|js.|jtd|jDr	d|_dS|jtj|_|}|j|		|d{V|j|n#|j|wxYwn/#tj
$r|js|wxYwd|_dS)zAcquire a lock.

        This method blocks until the lock is unlocked, then sets it to
        locked and returns True.
        Nc3>K|]}|VdSr	cancelled.0ws  r	<genexpr>zLock.acquire.<locals>.<genexpr>ds*99aAKKMM999999rT)r%r$allcollectionsdeque	_get_loop
create_futureappendremover
CancelledError_wake_up_firstrfuts  rrzLock.acquire]s-	$-"7994=99999#8DL4= '-//DMnn,,..
S!!!
	
*							
$$S))))
$$S)))))(			<
&##%%%	
tsB<!C<CC,Dch|jrd|_|dStd)aGRelease a lock.

        When the lock is locked, reset it to unlocked, and return.
        If any other coroutines 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%rHRuntimeErrorrs rrzLock.release}s<<	8 DL!!!!!6777rc|jsdS	tt|j}n#t$rYdSwxYw|s|ddSdS)z*Wake up the first waiter if it isn't done.NT)r$nextiter
StopIterationdone
set_resultrIs  rrHzLock._wake_up_firsts}	F	tDM**++CC			FF	xxzz	!NN4     	!	!s!-
;;)rrr__doc__r&r1r)rrrH
__classcell__r6s@rrrs33j*****@888"
!
!
!
!
!
!
!rrc@eZdZdZdZfdZdZdZdZdZ	xZ
S)ra#Asynchronous 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.
    cDtj|_d|_dSr#)rArBr$_valuers rr&zEvent.__init__s#)++
rct}|jrdnd}|jr|dt	|j}d|ddd|dS)	Nsetunsetr+r,r	r-r.r/)r0r1rXr$r2r3s   rr1zEvent.__repr__spgg  1'=	=<<DM(:(:<<E)3qt9))))))rc|jS)z5Return True if and only if the internal flag is true.rXrs ris_setzEvent.is_sets
{rc|js:d|_|jD]-}|s|d,dSdS)zSet the internal flag to true. All coroutines waiting for it to
        become true are awakened. Coroutine that call wait() once the flag is
        true will not block at all.
        TN)rXr$rQrRrIs  rrZz	Event.sets]
{	)DK}
)
)xxzz)NN4(((	)	)
)
)rcd|_dS)zReset the internal flag to false. Subsequently, coroutines calling
        wait() will block until set() is called to set the internal flag
        to true again.FNr]rs rclearzEvent.clearsrc"K|jrdS|}|j|	|d{V	|j|dS#|j|wxYw)zBlock until the internal flag is true.

        If the internal flag is true on entry, return True
        immediately.  Otherwise, block until another coroutine calls
        set() to set the flag to true, then return True.
        TN)rXrCrDr$rErFrIs  rwaitz
Event.waits;	4nn,,..
S!!!	&IIIIIIIM  %%%%%DM  %%%%s
A22B)rrrrSr&r1r^rZrarcrTrUs@rrrs*****
)
)
)&&&&&&&rrcDeZdZdZd
dZfdZdZdZddZd	Z	xZ
S)raAsynchronous equivalent to threading.Condition.

    This class implements condition variable objects. A condition variable
    allows one or more coroutines to wait until they are notified by another
    coroutine.

    A new Lock object is created and used as the underlying lock.
    Nc|t}||_|j|_|j|_|j|_tj|_dSr)r_lockr)rrrArBr$)rlocks  rr&zCondition.__init__sF<66D
k||#)++


rct}|rdnd}|jr|dt	|j}d|ddd|dSr()r0r1r)r$r2r3s   rr1zCondition.__repr__svgg   KKMM9z=	=<<DM(:(:<<E)3qt9))))))rcK|std|	|}|j|	|d{V	|j|d}		|d{Vn#tj
$rd}YnwxYw4|rtj
dS#|j|wxYw#d}		|d{Vn#tj
$rd}YnwxYw4|rtj
wxYw)aWait until notified.

        If the calling coroutine 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 coroutine.  Once
        awakened, it re-acquires the lock and returns True.
        zcannot wait on un-acquired lockNFT)r)rLrrCrDr$rErFrr
rG)rrJr;s   rrczCondition.waits{{}}	B@AAA	0..""0022CM  %%%
*							
$$S)))I
%%,,..(((((((!0%%% $III%	
%
0 //
0
0
$$S))))I
%%,,..(((((((!0%%% $III%	
%
0 //////sZAD<C&D#B>>CC&DDE
D%$E%D96E8D99EcnK|}|s&|d{V|}|&|S)zWait until a predicate becomes true.

        The predicate should be a callable which result will be
        interpreted as a boolean value.  The final predicate value is
        the return value.
        Nrc)r	predicateresults   rwait_forzCondition.wait_forsW	!))++Y[[F	!
rr	c|stdd}|jD]9}||krdS|s|dz
}|d:dS)aBy default, wake up one coroutine waiting on this condition, if any.
        If the calling coroutine has not acquired the lock when this method
        is called, a RuntimeError is raised.

        This method wakes up at most n of the coroutines waiting for the
        condition variable; it is a no-op if no coroutines are waiting.

        Note: an awakened coroutine 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 lockrr	FN)r)rLr$rQrR)rnidxrJs    rnotifyzCondition.notify*s{{}}	DBCCC=	&	&Caxx88::
&qu%%%
	&	&rcT|t|jdS)aWake 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)rrr2r$rs r
notify_allzCondition.notify_allBs&	
C
&&'''''rrr	)rrrrSr&r1rcrnrrrtrTrUs@rrrs
,
,
,
,*****#0#0#0J&&&&0(((((((rrcBeZdZdZd	dZfdZdZdZdZdZ	xZ
S)
raA 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.
    r	cL|dkrtdd|_||_dS)Nrz$Semaphore initial value must be >= 0)
ValueErrorr$rX)rvalues  rr&zSemaphore.__init__Zs,199CDDD
rct}|rdn	d|j}|jr|dt|j}d|ddd|dS)	Nr)zunlocked, value:r+r,r	r-r.r/)r0r1r)rXr$r2r3s   rr1zSemaphore.__repr__`sgg   KKMMO/O$+/O/O=	=<<DM(:(:<<E)3qt9))))))rcX|jdkptd|jpdDS)z9Returns True if semaphore cannot be acquired immediately.rc3@K|]}|VdSrr:r<s  rr?z#Semaphore.locked.<locals>.<genexpr>js-AAaAKKMM!AAAAAArr )rXanyr$rs rr)zSemaphore.lockedgs9{aCAADM,?RAAAAA	CrctK|s|xjdzc_dS|jtj|_|}|j|		|d{V|j|n#|j|wxYwnL#tj
$r:|s$|xjdz
c_|wxYw|jdkr|dS)a5Acquire 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 coroutine has
        called release() to make it larger than 0, and then return
        True.
        r	TNr)
r)rXr$rArBrCrDrErFr
rGr;
_wake_up_nextrIs  rrzSemaphore.acquirels@{{}}	KK1KK4= '-//DMnn,,..
S!!!
		
*							
$$S))))
$$S)))))(			==??
%q ""$$$		;??   ts
B-C
-C		C

A	DcN|xjdz
c_|dS)zRelease a semaphore, incrementing the internal counter by one.

        When it was zero on entry and another coroutine is waiting for it to
        become larger than zero again, wake up that coroutine.
        r	N)rXrrs rrzSemaphore.releases,	
qrc|jsdS|jD]>}|s(|xjdzc_|ddS?dS)z)Wake up the first waiter that isn't done.Nr	T)r$rQrXrRrIs  rrzSemaphore._wake_up_nextsj}	F=		C88::
q t$$$
		rru)rrrrSr&r1r)rrrrTrUs@rrrKs*****CCC
"""H							rrc.eZdZdZdfd	ZfdZxZS)rzA bounded semaphore implementation.

    This raises ValueError in release() if it would increase the value
    above the initial value.
    r	cX||_t|dSr)_bound_valuer0r&)rryr6s  rr&zBoundedSemaphore.__init__s)!
rc|j|jkrtdtdS)Nz(BoundedSemaphore released too many times)rXrrxr0r)rr6s rrzBoundedSemaphore.releases<;$+++GHHH
rru)rrrrSr&rrTrUs@rrrs`      rrceZdZdZdZdZdZdS)
_BarrierStatefillingdraining	resettingbrokenN)rrrFILLINGDRAINING	RESETTINGBROKENr rrrrs"GHI
FFFrrceZdZdZdZfdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZed
ZedZedZxZS)ra	Asyncio 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.
    c|dkrtdt|_||_tj|_d|_dS)z1Create a barrier, initialised to 'parties' tasks.r	zparties must be > 0rN)rxr_cond_partiesrr_state_count)rpartiess  rr&zBarrier.__init__sAQ;;2333[[

#+rct}|jj}|js|d|jd|jz
}d|ddd|dS)Nr+/r,r	r-r.r/)r0r1rryr	n_waitingrr3s   rr1zBarrier.__repr__spgg  ;$&{	BA$.AA4<AAAE)3qt9))))))rc:K|d{VSrrkrs rrzBarrier.__aenter__s(YY[[       rc
KdSrr )rargss  rrzBarrier.__aexit__srcK|j4d{V|d{V	|j}|xjdz
c_|dz|jkr|d{Vn|d{V||xjdzc_|cdddd{VS#|xjdzc_|wxYw#1d{VswxYwYdS)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  rrczBarrier.waits:								++--
q 19
----//))))))))**,,&&&&&&&q 

														q 

																s)C'AB>$C'>&C$$C''
C14C1cKjfdd{VjtjurtjddS)NcBjtjtjfvSr)rrrrrsr<lambda>z Barrier._block.<locals>.<lambda>sDK&
(?(rzBarrier aborted)rrnrrrr
BrokenBarrierErrorrs`rrzBarrier._blocksj!!





	
	
	
	
	
	
	
;-.../0ABBB/.rc^Ktj|_|jdSr)rrrrrtrs rrzBarrier._releases,
$,
rcKjfdd{Vjtjtjfvrt
jddS)Nc*jtjuSr)rrrrsrrzBarrier._wait.<locals>.<lambda>s$+]=R*RrzAbort or reset of barrier)rrnrrrrr
rrs`rrz
Barrier._waitsnj!!"R"R"R"RSSSSSSSSS;=/1HIII/0KLLLJIrc|jdkrK|jtjtjfvrtj|_|jdSdS)Nr)rrrrrrrrtrs rrz
Barrier._exitsU;!{}6
8NOOO+3J!!#####rc"K|j4d{V|jdkr%|jtjurtj|_ntj|_|jdddd{VdS#1d{VswxYwYdS)zReset the barrier to the initial state.

        Any tasks currently waiting will get the BrokenBarrier exception
        raised.
        Nr)rrrrrrrtrs rresetz
Barrier.reset#s:	$	$	$	$	$	$	$	${Q;m&==="/"9DK+3J!!###	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$sAA>>
BBcK|j4d{Vtj|_|jdddd{VdS#1d{VswxYwYdS)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)rrrrrtrs rabortz
Barrier.abort2s:	$	$	$	$	$	$	$	$'.DKJ!!###	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$s+A
AAc|jS)z8Return the number of tasks required to trip the barrier.)rrs rrzBarrier.parties<s}rc:|jtjur|jSdS)z<Return the number of tasks currently waiting at the barrier.r)rrrrrs rrzBarrier.n_waitingAs!;-///;qrc(|jtjuS)z0Return True if the barrier is in a broken state.)rrrrs rrzBarrier.brokenHs{m222r)rrrrSr&r1rrrcrrrrrrpropertyrrrrTrUs@rrrs/			*****!!!



.CCC    	M	M	M$$$
$
$
$$$$XX33X33333rr)rS__all__rAenumr
rrr_LoopBoundMixinrrrrrEnumrrr rr<module>rs!!*C!C!C!C!C!!7C!C!C!L:&:&:&:&:&F":&:&:&zm(m(m(m(m($f&<m(m(m(`WWWWW$f&<WWWty$DIM3M3M3M3M3f$M3M3M3M3M3r