+\h(dZddlmZddlZddlZddlmZmZddlm Z m Z m Z ejZ GddZGdd ZGd d eeZ Gd d eeZy)zLock and Condition classes vendored from https://github.com/python/cpython/blob/main/Lib/asyncio/locks.py to port 3.13 fixes to older versions of Python. Can be removed once we drop Python 3.12 support.) annotationsN)events exceptions)Any CoroutineOptionalceZdZdZddZy)_LoopBoundMixinNctj}|j"t5|j||_ddd||jurt |d|S#1swY'xYw)Nz# is bound to a different event loop)r_get_running_loop_loop _global_lock RuntimeError)selfloops X/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/_asyncio_lock.py _get_loopz_LoopBoundMixin._get_loopsi'') ::  &::%!%DJ & tzz !$)LMN N  & &s A!!A*)returnr)__name__ __module__ __qualname__r rrr r s E rr ceZdZddZddZy)_ContextManagerMixinc@K|jd{y7wN)acquirers r __aenter__z_ContextManagerMixin.__aenter__!slln  s c,K|jywr)release)rexc_typeexctbs r __aexit__z_ContextManagerMixin.__aexit__'s sNrNone)r#rr$rr%rrr()rrrr r&rrrrr s  rrcLeZdZdZddZd fd Zd dZd dZddZddZ xZ S) Locka5Primitive 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 d|_d|_y)NF)_waiters_lockedrs r__init__z Lock.__init___s59  rct|}|jrdnd}|jr|dt |j}d|ddd|dS Nlockedunlockedz , waiters:<z [z]>)super__repr__r-r,lenrresextra __class__s rr7z Lock.__repr__csYg  LLj ==gZDMM(:';zLock.acquire..ws(N1(NsT) r-r,all collectionsdequer create_futureappendremoverCancelledError_wake_up_firstrfuts rrz Lock.acquirens|| MM !S(N (N%NDL == '--/DMnn,,. S!  *  $$S)  $$S)((  <<##%  sBBD#C$C %C)C/D# CC,,C//1D  D#c`|jrd|_|jytd)aBRelease 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 acquiredN)r-rKrrs rr"z Lock.releases* << DL    !56 6rc|jsy tt|j}|j s|j dyy#t$rYywxYw)z*Ensure that the first waiter will wake up.NT)r,nextiter StopIterationdone set_resultrLs rrKzLock._wake_up_firstsT}}  tDMM*+C xxz NN4     sA AAr'rstrrbool) rrr__doc__r.r7r1rr"rK __classcell__r<s@rr*r*+s(1f*$L7" !rr*cXeZdZdZd d dZd fd Zd dZd dZdddZddZ ddZ xZ S) ConditionaAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more tasks to wait until they are notified by another task. A new Lock object is created and used as the underlying lock. c| t}||_|j|_|j|_|j|_t j |_yr)r*_lockr1rr"rErFr,)rlocks rr.zCondition.__init__sF <6D kk || || +6+<+<+> rct|}|jrdnd}|jr|dt |j}d|ddd|dSr0)r6r7r1r,r8r9s rr7zCondition.__repr__s[g  KKMz ==gZDMM(:';| |#d}wxYwwxYw#t$r|jdwxYww)a&Wait until notified. If the calling task 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 task. Once awakened, it re-acquires the lock and returns True. This method may return spuriously, which is why the caller should always re-check the state and be prepared to wait() again. zcannot wait on un-acquired lockNTr4) r1rrrGr"r,rHrIrrrJ BaseException_notify)rrMerres rwaitzCondition.waitsv{{}@A Ann,,. !  # $$S).IIMM((-  "lln,,?#! ##-%44  #%MM((-  "lln,,%44  ?#! " #   LLO  sA E2D*C!/B30C!5DEB7'B5(B7,E0C2E23C!5B77C C ECECE!C>>DED DD E D?3D:5E:D??EEE  EEE//E2chK|}|s"|jd{|}|s"|S7w)aWait 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. N)rg)r predicateresults rwait_forzCondition.wait_fors9))+  [F  s20 22c\|js td|j|y)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)r1rrd)rns rnotifyzCondition.notifys${{}BC C Qrcd}|jD]0}||k\ry|jr|dz }|jd2y)Nrr4F)r,rSrT)rrmidxrMs rrdzCondition._notify%sB== &Cax88:qu%  &rcL|jt|jy)aWake up all tasks waiting on this condition. This method acts like notify(), but wakes up all waiting tasks instead of one. If the calling task has not acquired the lock when this method is called, a RuntimeError is raised. N)rnr8r,rs r notify_allzCondition.notify_all/s C &'rr)r`zOptional[Lock]rr(rUrW)rirrr)r4)rmintrr(r') rrrrYr.r7rgrkrnrdrrrZr[s@rr]r]s, ?*5n  &(rr])rY __future__rrE threadingasynciorrtypingrrrr*rr rr]rrrrxsc4#&++y~~   E! E!PB($oB(r