
    Ii|                         % S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	J
r
JrJr  \" \S5      r\R                  " 5       rS\S'   \" S5      rSS jrSS	 jrSS
 jr " S S5      rSS jr " S S5      rg)    )annotationsN)AnyCallableOptionalTypeVarregister_at_forkzweakref.WeakSet[threading.Lock]_forkable_locks_Tc                 p    [         R                  " 5       n [        (       a  [        R	                  U 5        U $ )zhRepresents a lock that is tracked upon instantiation using a WeakSet and
reset by pymongo upon forking.
)	threadingLock_HAS_REGISTER_AT_FORKr	   addlocks    2/venv/lib/python3.13/site-packages/pymongo/lock.py_create_lockr       s)     >>DD!K    c                 l    [          H*  n U R                  5       (       d  M  U R                  5         M,     g N)r	   lockedreleaser   s    r   _release_locksr   *   s     ;;==LLN  r   c                    U $ r    r   s    r   _Lockr   2   s    Kr   c                  p    \ rS rSrSrSS jrSSS jjrSSS jjrSS jrSS jr	SS jr
SS	 jrSS
 jrSrg)_ALock6   _lockc                    Xl         g r   r    )selfr   s     r   __init___ALock.__init__9   s    
r   c                4    U R                   R                  XS9$ )N)blockingtimeoutr!   acquire)r#   r'   r(   s      r   r*   _ALock.acquire<   s    zz!!8!EEr   c                  #    US:  a  [         R                  " 5       n U R                  R                  SS9nU(       a  gUS:  a  [         R                  " 5       W-
  U:  a  gU(       d  g[        R
                  " S5      I S h  vN   Ml   N7fNr   TF)r'   )time	monotonicr!   r*   asynciosleepr#   r'   r(   tstartacquireds        r   	a_acquire_ALock.a_acquire?   sw     Q;^^%Fzz))5)9H{ 06 9WD--"""  #   BBBBc                8    U R                   R                  5         g r   )r!   r   r#   s    r   r   _ALock.releaseL   s    

r   c                B   #    U R                  5       I S h  vN   U $  N7fr   )r5   r9   s    r   
__aenter___ALock.__aenter__O   s     nn 	   c                :    U R                   R                  5         U $ r   r)   r9   s    r   	__enter___ALock.__enter__S   s    

r   c                $    U R                  5         g r   r   r#   exc_typeexctbs       r   __exit___ALock.__exit__W       r   c                ,   #    U R                  5         g 7fr   rC   rD   s       r   	__aexit___ALock.__aexit__Z           N)r   threading.LockreturnNoneTr'   boolr(   floatrQ   rV   rQ   rR   )rQ   r   rE   r   rF   r   rG   r   rQ   rR   )__name__
__module____qualname____firstlineno__	__slots__r$   r*   r5   r   r<   r@   rH   rL   __static_attributes__r   r   r   r   r   6   s0    IF#r   r   c                R    U R                  5       (       d  U R                  S5        g g )NF)done
set_result)futs    r   _safe_set_resultrd   ^   s    88::u r   c                      \ rS rSrSrSS jrSSS jjrSSS jjrSS jrSSS jjr	SS	 jr
SS
 jrSS jrSS jrSS jrSS jrSS jrSrg)_AConditiond   )
_condition_waitersc                D    Xl         [        R                  " 5       U l        g r   )rh   collectionsdequeri   )r#   	conditions     r   r$   _ACondition.__init__g   s    #+6+<+<+>r   c                  #    US:  a  [         R                  " 5       n U R                  R                  SS9nU(       a  gUS:  a  [         R                  " 5       W-
  U:  a  gU(       d  g[        R
                  " S5      I S h  vN   Ml   N7fr-   )r.   r/   rh   r*   r0   r1   r2   s        r   r*   _ACondition.acquirek   sw     Q;^^%F...>H{ 06 9WD--"""  #r7   Nc                :  #    [         R                  " 5       nUR                  5       nU R                  R	                  X#45        U R                  5            [         R                  " X15      I Sh  vN    Sn  U R                  5       I Sh  vN    U R                  R                  X#45        Ub   Ueg NE N*! [         R                  R                   a  nUn SnAOSnAff = fMp  ! Snf = f! [         R                   ay     Sn  U R                  5       I Sh  vN    O/! [         R                  R                   a  nUn SnAOSnAff = fMJ  U R                  R                  X#45        Ub
   Ue! Snf = fgf = f! Sn  U R                  5       I Sh  vN    O/! [         R                  R                   a  nUn SnAOSnAff = fMJ  U R                  R                  X#45        Ub
   Ue! Snf = ff = f! [         a    U R                  S5        e f = f7f)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.
NTF   )r0   get_running_loopcreate_futureri   appendr   wait_forr*   
exceptionsCancelledErrorremoveTimeoutErrorBaseExceptionnotify)r#   r(   looprc   erres         r   wait_ACondition.waitx   s     '')  "d[) 	#!!**3888  "lln,, $$d[1?#!	 ## 9 -"--<<   	  #' ++ ! 
  "lln,,"--<<   	  $$d[1?#!	"	 #!  "lln,,"--<<   	  $$d[1?#!	"	 #
  	 KKN	sD  AHC0 0B61C0 6G; :B: B8B:  G; 3C) 5H6C0 8B: :C$CG; C$$G; )C--G; 0E=F  G; 	D# DD# "G; #EEG; E$G; 2E4 4E88G; ;H<E==F   G8FFFG8G	=G?G8G		$G8.G00G44G88G; ;HHc                ~   #    U" 5       nU(       d(  U R                  5       I Sh  vN   U" 5       nU(       d  M(  U$  N7f)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.
N)r   )r#   	predicateresults      r   rv   _ACondition.wait_for   s:      ))+[F &  s   "=;==c                8   Sn/ nU R                    H?  u  pEX!:  a    O7UR                  5       (       a  M#   UR                  [        U5        US-  nMA     U H  nU R                   R                  U5        M      g! [         a    UR                  XE45         M  f = f)a  By 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.
r   rr   N)ri   ra   call_soon_threadsaferd   RuntimeErrorru   ry   )r#   nidx	to_remover}   rc   waiters          r   r|   _ACondition.notify   s     	IDxxxzz))*:C@ 1HC '   FMM  (       $-s   A99BBc                L    U R                  [        U R                  5      5        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)r|   lenri   r9   s    r   
notify_all_ACondition.notify_all   s     	C&'r   c                J    U R                   R                  R                  5       $ )z$Only needed for tests in test_locks.)rh   r!   r   r9   s    r   r   _ACondition.locked   s    $$++--r   c                8    U R                   R                  5         g r   )rh   r   r9   s    r   r   _ACondition.release   s    !r   c                B   #    U R                  5       I S h  vN   U $  N7fr   )r*   r9   s    r   r<   _ACondition.__aenter__   s     lln 	r>   c                :    U R                   R                  5         U $ r   )rh   r*   r9   s    r   r@   _ACondition.__enter__   s    !r   c                ,   #    U R                  5         g 7fr   rC   rD   s       r   rL   _ACondition.__aexit__   rN   rO   c                $    U R                  5         g r   rC   rD   s       r   rH   _ACondition.__exit__   rJ   r   )rm   zthreading.ConditionrQ   rR   rS   rU   r   )r(   zOptional[float]rQ   rV   )r   zCallable[[], _T]rQ   r
   )rr   )r   intrQ   rR   rX   )rQ   rV   )rQ   rf   rY   )rZ   r[   r\   r]   r^   r$   r*   r   rv   r|   r   r   r   r<   r@   rL   rH   r_   r   r   r   rf   rf   d   sE    *I?#3j)B(."r   rf   )rQ   rP   rX   )r   rP   rQ   rP   )rc   zasyncio.FuturerQ   rR   )
__future__r   r0   rk   osr   r.   weakreftypingr   r   r   r   hasattrr   WeakSetr	   __annotations__r
   r   r   r   r   rd   rf   r   r   r   <module>r      sx    #   	    3 3$67  4;??3D0 DT]% %PS Sr   