+
    P\iQ  c                  sV   ^ RI Ht ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^RIHt ^R	IHt ^R
IHtHt ^RIHt ^RIHtHt ]! R4      t]! RR7       ! R R4      4       t]! RR7       ! R R4      4       t]! RR7       ! R R4      4       t]! RR7       ! R R4      4       t]! RR7       ! R R4      4       t ! R R4      t ! R R]4      t  ! R R4      t! ! R  R!]!4      t" ! R" R#4      t# ! R$ R%4      t$ ! R& R']$4      t% ! R( R)4      t& ! R* R+]&4      t' ! R, R-4      t(R# ).i    )annotationsN)deque)Callable)	dataclass)TracebackType)TypeVar)checkpoint_if_cancelled)get_async_backend)BusyResourceErrorNoEventLoopError)CancelScope)TaskInfoget_current_taskTT)Zfrozenc                  s&    ] tR t^t$ RtR]R&   RtR# )EventStatisticszJ
:ivar int tasks_waiting: number of tasks waiting on :meth:`~.Event.wait`
inttasks_waiting N__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r       A/usr/lib/python3.14/site-packages/anyio/_core/_synchronization.pyr   r      s     r   r   c                  sD    ] tR t^t$ RtR]R&   R]R&   R]R&   R]R&   R	tR
# )CapacityLimiterStatisticsaz  
:ivar int borrowed_tokens: number of tokens currently borrowed by tasks
:ivar float total_tokens: total number of available tokens
:ivar tuple borrowers: tasks or other objects currently holding tokens borrowed from
    this limiter
:ivar int tasks_waiting: number of tasks waiting on
    :meth:`~.CapacityLimiter.acquire` or
    :meth:`~.CapacityLimiter.acquire_on_behalf_of`
r   borrowed_tokensfloattotal_tokensztuple[object, ...]	borrowersr   r   Nr   r   r   r   r   r      s!     !!r   r   c                  s:    ] tR t^.t$ RtR]R&   R]R&   R]R&   RtR	# )
LockStatisticsa   
:ivar bool locked: flag indicating if this lock is locked or not
:ivar ~anyio.TaskInfo owner: task currently holding the lock (or ``None`` if the
    lock is not held by any task)
:ivar int tasks_waiting: number of tasks waiting on :meth:`~.Lock.acquire`
boollockedTaskInfo | NoneZownerr   r   r   Nr   r   r   r   r!   r!   .   s     Lr   r!   c                  s0    ] tR t^<t$ RtR]R&   R]R&   RtR# )ConditionStatisticsz
:ivar int tasks_waiting: number of tasks blocked on :meth:`~.Condition.wait`
:ivar ~anyio.LockStatistics lock_statistics: statistics of the underlying
    :class:`~.Lock`
r   r   r!   Zlock_statisticsr   Nr   r   r   r   r%   r%   <   s     ##r   r%   c                  s&    ] tR t^Ht$ RtR]R&   RtR# )SemaphoreStatisticszR
:ivar int tasks_waiting: number of tasks waiting on :meth:`~.Semaphore.acquire`

r   r   r   Nr   r   r   r   r&   r&   H   s    
 r   r&   c                  sR    ] tR t^RtR R ltR R ltR R ltR R ltR	 R
 ltRt	R# )Eventc                   V ^8  d   QhRR/#    returnr'   r   Zformat   "r   __annotate__Event.__annotate__S   s     " " "r   c                	sj     \        4       P                  4       #   \         d    \        4       u # i ; iN)r   create_eventr	   EventAdaptercls   &r   __new__ZEvent.__new__S   s0    	"$&3355 	">!	"s    22c               r(   r*   r+   Noner   r,   r-   r   r.   r/   Y   s     " "T "r   c                    \         h)z&Set the flag, notifying all listeners.ZNotImplementedErrorselfr5   r   setZ	Event.setY       !!r   c               r(   r*   r+   r"   r   r,   r-   r   r.   r/   ]        " " "r   c                r9   )z5Return ``True`` if the flag is set, ``False`` if not.r:   r;   r5   r   is_setZEvent.is_set]   r>   r   c               r(   r7   r   r,   r-   r   r.   r/   a   s     " "D "r   c                   "   \         h5i)zz
Wait until the flag has been set.

If the flag has already been set when this method is called, it returns
immediately.

r:   r;   r5   r   waitZ
Event.waita   s      "!   	c               r(   r*   r+   r   r   r,   r-   r   r.   r/   k   s     " "O "r   c                r9   )z8Return statistics about the current state of this event.r:   r;   r5   r   
statisticsZEvent.statisticsk   r>   r   r   N)
r   r   r   r   r6   r=   rA   rC   rF   r   r   r   r   r'   r'   R   s     """"" "r   r'   c                  s    ] tR t^pt$ RtR]R&   RtR]R&   R R lt]R	 R
 l4       t	R R lt
R R ltR R ltR R ltRtR# )r2   NzEvent | None_internal_eventFr"   _is_setc               r(   )r*   r+   r2   r   r,   r-   r   r.   EventAdapter.__annotate__t   s     # # #r   c                	,    \         P                  V 4      # r0   objectr6   r3   r5   r   r6   ZEventAdapter.__new__t       ~~c""r   c               r(   r)   r   r,   r-   r   r.   rI   x   s     $ $ $r   c                	s    V P                   fJ   \        4       P                  4       V n         V P                  '       d   V P                   P	                  4        V P                   # r0   )rG   r   r1   rH   r=   r;   r5   r   _eventZEventAdapter._eventw   sI    '#4#6#C#C#ED |||$$((*###r   c               r(   r7   r   r,   r-   r   r.   rI      s      T r   c                	sh    V P                   f
   RV n        R # V P                  P                  4        R # )NT)rG   rH   rN   r=   r;   r5   r   r=   ZEventAdapter.set   s#    'DLKKOOr   c               r(   r?   r   r,   r-   r   r.   rI      s     - - -r   c                	sj    V P                   f   V P                  # V P                   P                  4       # r0   )rG   rH   rA   r;   r5   r   rA   ZEventAdapter.is_set   s-    '<<##**,,r   c               r(   r7   r   r,   r-   r   r.   rI      s     ! !D !r   c                	V   "   V P                   P                  4       G R j  xL
  R #  L5ir0   )rN   rC   r;   r5   r   rC   ZEventAdapter.wait   s     kk      )')c               r(   rE   r   r,   r-   r   r.   rI      s     1 1O 1r   c                	sj    V P                   f   \        ^ R7      # V P                   P                  4       # N)r   )rG   r   rF   r;   r5   r   rF   ZEventAdapter.statistics   s.    '"33##..00r   )rG   rH   )r   r   r   r   rG   r   rH   r6   propertyrN   r=   rA   rC   rF   r   r   r   r   r2   r2   p   sH    $(O\(GT# $ $-!1 1r   r2   c                  s~    ] tR t^tRR/R R lltR R ltR R ltR	 R
 ltR R ltR R lt	R R lt
R R ltRtR# )Lockfast_acquireFc                    V ^8  d   QhRRRR/# )r*   rT   r"   r+   rS   r   r,   r-   r   r.   Lock.__annotate__   s     : :d :t :r   c               	sr     \        4       P                  VR 7      #   \         d    \        TR 7      u # i ; i)rT   )r   create_lockr	   LockAdapterr4   rT      &$r   r6   ZLock.__new__   s8    	:$&222MM 	:L99	:s    66c               r(   r7   r   r,   r-   r   r.   rV            $ r   c                	B   "   V P                  4       G R j  xL
  R #  L5ir0   acquirer;   r5   r   
__aenter__ZLock.__aenter__        lln   c               (    V ^8  d   QhRRRRRRRR/# 	r*   exc_typeztype[BaseException] | Noneexc_valzBaseException | Noneexc_tbzTracebackType | Noner+   r8   r   r,   r-   r   r.   rV      2      , & %	
 
r   c                	.   "   V P                  4        R # 5ir0   releaser<   re   rf   rg      &&&&r   	__aexit__ZLock.__aexit__         	   c               r(   r7   r   r,   r-   r   r.   rV           " "t "r   c                rB   )Acquire the lock.r:   r;   r5   r   r_   ZLock.acquire        !!rD   c               r(   r7   r   r,   r-   r   r.   rV           " " "r   c                r9   )_
Acquire the lock, without blocking.

:raises ~anyio.WouldBlock: if the operation would block

r:   r;   r5   r   acquire_nowaitZLock.acquire_nowait   
     "!r   c               r(   r7   r   r,   r-   r   r.   rV           " " "r   c                r9   )Release the lock.r:   r;   r5   r   rk   ZLock.release   r>   r   c               r(   r?   r   r,   r-   r   r.   rV      r@   r   c                r9   z*Return True if the lock is currently held.r:   r;   r5   r   r#   ZLock.locked   r>   r   c               r(   r*   r+   r!   r   r,   r-   r   r.   rV      s     " "N "r   c                r9   )zP
Return statistics about the current state of this lock.

.. versionadded:: 3.0
r:   r;   r5   r   rF   ZLock.statistics   
     "!r   r   N)r   r   r   r   r6   r`   rn   r_   rv   rk   r#   rF   r   r   r   r   rS   rS      s6    :U :""""" "r   rS   c                  s    ] tR t^t$ RtR]R&   RR/R R lltRR/R R	 llt]R
 R l4       t	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltRtR# )rY   NLock | None_internal_lockrT   Fc               rU   )r*   rT   r"   r+   rY   r   r,   r-   r   r.   LockAdapter.__annotate__   s     # #d #{ #r   c               	rJ   r0   rK   rZ   r[   r   r6   ZLockAdapter.__new__   rM   r   c               r(   )r*   rT   r"   r   r,   r-   r   r.   r      s     * * *r   c               	    Wn         R # r0   _fast_acquire)r<   rT   r[   r   __init__ZLockAdapter.__init__   s    )r   c               r(   )r*   r+   rS   r   r,   r-   r   r.   r      s     # #t #r   c                	s    V P                   f*   \        4       P                  V P                  R7      V n         V P                   # )NrW   )r~   r   rX   r   r;   r5   r   _lockZLockAdapter._lock   sA    &"3"5"A"A!// #B #D """r   c               r(   r7   r   r,   r-   r   r.   r      s     # #$ #r   c                	rO   r0   r   r_   r;   r5   r   r`   ZLockAdapter.__aenter__   s     jj  """rP   c               rc   rd   r   r,   r-   r   r.   r      s2     * *,* &* %	*
 
*r   c                	sb   "   V P                   e   V P                   P                  4        R # R # 5ir0   )r~   rk   rl   rm   r   rn   ZLockAdapter.__aexit__   s*      *'') +s   -/c               r(   r7   r   r,   r-   r   r.   r      s     # #t #r   c                sV   "   V P                   P                  4       G Rj  xL
  R#  L5i)rr   Nr   r;   r5   r   r_   ZLockAdapter.acquire   s     jj  """rP   c               r(   r7   r   r,   r-   r   r.   r      s     $ $ $r   c                :    V P                   P                  4        R# )ru   N)r   rv   r;   r5   r   rv   ZLockAdapter.acquire_nowait   s     	

!!#r   c               r(   r7   r   r,   r-   r   r.   r             r   c                r   )ry   Nr   rk   r;   r5   r   rk   ZLockAdapter.release       

r   c               r(   r?   r   r,   r-   r   r.   r           # # #r   c                6    V P                   P                  4       # rz   r   r#   r;   r5   r   r#   ZLockAdapter.locked       zz  ""r   c               r(   r{   r   r,   r-   r   r.   r      s     
0 
0N 
0r   c                sl    V P                   f   \        RR^ 4      # V P                   P                  4       # )zQ
Return statistics about the current state of this lock.

.. versionadded:: 3.0

NF)r~   r!   rF   r;   r5   r   rF   ZLockAdapter.statistics   s4     &!%q11""--//r   )r   r~   )r   r   r   r   r~   r   r6   r   rR   r   r`   rn   r_   rv   rk   r#   rF   r   r   r   r   rY   rY      s`    "&NK&#U #*u * # ##*#$#
0 
0r   rY   c                  s    ] tR tRt$ RtR]R&   R R R lltR R ltR	 R
 ltR R lt	R R lt
R R ltR R ltR R ltR!R R lltR R ltR R ltR R ltR R ltRtR# )"	Conditioni  Nr$   _owner_taskc               r(   )r*   lockr}   r   r,   r-   r   r.   Condition.__annotate__	  s     . .[ .r   c                	sV    T;'       g    \        4       V n        \        4       V n        R # r0   )rS   r   r   _waiters)r<   r      &&r   r   ZCondition.__init__	  s    ^^TV
&+gr   c               r(   r7   r   r,   r-   r   r.   r     r\   r   c                	r]   r0   r^   r;   r5   r   r`   ZCondition.__aenter__  ra   rb   c               rc   rd   r   r,   r-   r   r.   r     rh   r   c                	ri   r0   rj   rl   rm   r   rn   ZCondition.__aexit__  ro   rp   c               r(   r7   r   r,   r-   r   r.   r     s     V V Vr   c                	sN    V P                   \        4       8w  d   \        R 4      hR# )z3The current task is not holding the underlying lockN)r   r   ZRuntimeErrorr;   r5   r   _check_acquiredZCondition._check_acquired  s%    /11TUU 2r   c               r(   r7   r   r,   r-   r   r.   r     s     . .t .r   c                st   "   V P                   P                  4       G Rj  xL
  \        4       V n        R#  L5i)zAcquire the underlying lock.N)r   r_   r   r   r;   r5   r   r_   ZCondition.acquire  s+     jj  """+- 	#s   868c               r(   r7   r   r,   r-   r   r.   r   !  s     . . .r   c                sX    V P                   P                  4        \        4       V n        R# )j
Acquire the underlying lock, without blocking.

:raises ~anyio.WouldBlock: if the operation would block

N)r   rv   r   r   r;   r5   r   rv   ZCondition.acquire_nowait!  s     	

!!#+-r   c               r(   r7   r   r,   r-   r   r.   r   +  r   r   c                r   )zRelease the underlying lock.Nr   r;   r5   r   rk   ZCondition.release+  r   r   c               r(   r?   r   r,   r-   r   r.   r   /  r   r   c                r   )zReturn True if the lock is set.r   r;   r5   r   r#   ZCondition.locked/  r   r   c               rU   )r*   nr   r+   r8   r   r,   r-   r   r.   r   3  s     	 	 	D 	r   c                s    V P                  4        \        V4       F.  p V P                  P                  4       pTP                  4        K0  	  R#   \         d      R# i ; i)zNotify exactly n listeners.N)r   Zranger   ZpopleftZ
IndexErrorr=   )r<   r   Z_events   &&  r   notifyZCondition.notify3  sR    qA--/ IIK   s   AA A c               r(   r7   r   r,   r-   r   r.   r   >  s      D r   c                s    V P                  4        V P                   F  pVP                  4        K  	  V P                  P                  4        R# )zNotify all the listeners.N)r   r   r=   Zclearr<   r      & r   
notify_allZCondition.notify_all>  s7    ]]EIIK # 	r   c               r(   r7   r   r,   r-   r   r.   r   F  s     % %D %r   c           	     s  "   \        4       G Rj  xL
  V P                  4        \        4       pV P                  P	                  V4       V P                  4         VP                  4       G Rj  xL
   \        RR7      ;_uu_ 4        T P                  4       G Rj  xL
  RRR4       R#  L L>  \         d4    TP                  4       '       g   T P                  P                  T4       h i ; i LS  + '       g   i     R# ; i  \        RR7      ;_uu_ 4        T P                  4       G Rj  xL 
  RRR4       i   + '       g   i     i ; i; i5i)zWait for a notification.NT)Zshield)r   r   r'   r   Zappendrk   rC   ZBaseExceptionrA   Zremover
   r_   r   r   r   rC   ZCondition.waitF  s     %'''U#		%**, D))lln$$ *) 	(  	<<>>$$U+		 % *))D))lln$$ *)))s   EB+A	EB/ .B-/B/ 4EC2C0C2!E-B/ / C-C--D 0C22D	=	EED>	/D20D>	5	E>E	EEc               rU   )r*   	predicatezCallable[[], T]r+   r   r   r,   r-   r   r.   r   X  s       A r   c                sd   "   V! 4       ;p'       g   V P                  4       G Rj  xL
  K)  V#  L5i)z
Wait until a predicate becomes true.

:param predicate: a callable that returns a truthy value when the condition is
    met
:return: the result of the predicate

.. versionadded:: 4.11.0

N)rC   )r<   r   Zresults   && r   wait_forZCondition.wait_forX  s-      '[(6())+ s   00.	0c               r(   )r*   r+   r%   r   r,   r-   r   r.   r   h  s     P P/ Pr   c                sp    \        \        V P                  4      V P                  P	                  4       4      # )zU
Return statistics about the current state of this condition.

.. versionadded:: 3.0
)r%   Zlenr   r   rF   r;   r5   r   rF   ZCondition.statisticsh  s'     #3t}}#5tzz7L7L7NOOr   )r   r   r   r0   )i   )r   r   r   r   r   r   r   r`   rn   r   r_   rv   rk   r#   r   r   rC   r   rF   r   r   r   r   r   r     sU    #'K'.V.
.#	%$ P Pr   r   c                  s    ] tR tRtRRRR/R R lltRRRR/R R	 lltR
 R ltR R ltR R ltR R lt	R R lt
]R R l4       t]R R l4       tR R ltRtR# )	Semaphoreiq  	max_valueNrT   Fc               rc   )	r*   initial_valuer   r   
int | NonerT   r"   r+   r   r   r,   r-   r   r.   Semaphore.__annotate__r  s8     H HH 	H
 H 
Hr   c               	st     \        4       P                  WVR 7      #   \         d    \        YR7      u # i ; i)r   rT   r   )r   create_semaphorer	   SemaphoreAdapterr4   r   r   rT      &&$$r   r6   ZSemaphore.__new__r  sF    	H$&77 8     	H#MGG	Hs    77c               s$    V ^8  d   QhRRRRRR/# )r*   r   r   r   r   rT   r"   r   r,   r-   r   r.   r     s(     * ** 	*
 *r   c               	s    \        V\        4      '       g   \        R 4      hV^ 8  d   \        R4      hVe3   \        V\        4      '       g   \        R4      hW!8  d   \        R4      hW0n        R# )z initial_value must be an integerzinitial_value must be >= 0Nz$max_value must be an integer or Nonez7max_value must be equal to or higher than initial_value)
isinstancer   	TypeError
ValueErrorr   )r<   r   r   rT   r   r   r   ZSemaphore.__init__  sn     --->??19:: i-- FGG( M  *r   c               r(   r*   r+   r   r   r,   r-   r   r.   r     s      ) r   c                	sB   "   V P                  4       G R j  xL
  V #  L5ir0   r^   r;   r5   r   r`   ZSemaphore.__aenter__  s     lln 	rb   c               rc   rd   r   r,   r-   r   r.   r     rh   r   c                	ri   r0   rj   rl   rm   r   rn   ZSemaphore.__aexit__  ro   rp   c               r(   r7   r   r,   r-   r   r.   r     rq   r   c                rB   )z5Decrement the semaphore value, blocking if necessary.r:   r;   r5   r   r_   ZSemaphore.acquire  rs   rD   c               r(   r7   r   r,   r-   r   r.   r     rt   r   c                r9   )r   r:   r;   r5   r   rv   ZSemaphore.acquire_nowait  rw   r   c               r(   r7   r   r,   r-   r   r.   r     rx   r   c                r9   )zIncrement the semaphore value.r:   r;   r5   r   rk   ZSemaphore.release  r>   r   c               r(   r*   r+   r   r   r,   r-   r   r.   r     s     " "s "r   c                r9   )z#The current value of the semaphore.r:   r;   r5   r   valueZSemaphore.value  
     "!r   c               r(   r*   r+   r   r   r,   r-   r   r.   r     s     " ": "r   c                r9   )z#The maximum value of the semaphore.r:   r;   r5   r   r   ZSemaphore.max_value  r   r   c               r(   r*   r+   r&   r   r,   r-   r   r.   r     s     " "/ "r   c                r9   )zU
Return statistics about the current state of this semaphore.

.. versionadded:: 3.0
r:   r;   r5   r   rF   ZSemaphore.statistics  r|   r   r   )r   r   r   r   r6   r   r`   rn   r_   rv   rk   rR   r   r   rF   r   r   r   r   r   r   q  s    H !%	H
 #H* !%	*
 #**""" " " " "" "r   r   c                  s   a  ] tR tRt$ RtR]R&   RRRR/R R	 lltRRRR/R
 V 3R lllt]R R l4       t	R R lt
R R ltR R lt]R R l4       t]R R l4       tR R ltRtV ;t# )r   i  NzSemaphore | None_internal_semaphorer   rT   Fc               rc   )	r*   r   r   r   r   rT   r"   r+   r   r   r,   r-   r   r.   SemaphoreAdapter.__annotate__  s2     # ## 	#
 # 
#r   c               	rJ   r0   rK   r   r   r   r6   ZSemaphoreAdapter.__new__  s     ~~c""r   c               rc   )	r*   r   r   r   r   rT   r"   r+   r8   r   r,   r-   r   r.   r     s2     	$ 	$	$ 		$
 	$ 
	$r   c               	sB   < \         SV `  WVR 7       Wn        W n        R# )r   N)Zsuperr   _initial_value
_max_value)r<   r   r   rT   	__class__s   &&$$r   r   ZSemaphoreAdapter.__init__  s"     	,W+#r   c               r(   r   r   r,   r-   r   r.   r     s     ( (I (r   c                	s    V P                   f5   \        4       P                  V P                  V P                  R7      V n         V P                   # )Nr   )r   r   r   r   r   r;   r5   r   
_semaphoreZSemaphoreAdapter._semaphore  sG    ##+'8':'K'K##t (L (D$ '''r   c               r(   r7   r   r,   r-   r   r.   r     s     ( (t (r   c                	rO   r0   )r   r_   r;   r5   r   r_   ZSemaphoreAdapter.acquire  s     oo%%'''rP   c               r(   r7   r   r,   r-   r   r.   r     s     ) ) )r   c                	:    V P                   P                  4        R # r0   )r   rv   r;   r5   r   rv   ZSemaphoreAdapter.acquire_nowait  s    &&(r   c               r(   r7   r   r,   r-   r   r.   r     s     " " "r   c                	r   r0   )r   rk   r;   r5   r   rk   ZSemaphoreAdapter.release  s    !r   c               r(   r   r   r,   r-   r   r.   r     s     % %s %r   c                	sb    V P                   f   V P                  # V P                  P                  # r0   )r   r   r   r   r;   r5   r   r   ZSemaphoreAdapter.value  s*    ##+&&&$$$r   c               r(   r   r   r,   r-   r   r.   r     s      : r   c                	s    V P                   # r0   )r   r;   r5   r   r   ZSemaphoreAdapter.max_value  s    r   c               r(   r   r   r,   r-   r   r.   r     s     , ,/ ,r   c                	sj    V P                   f   \        ^ R7      # V P                  P                  4       # rQ   )r   r&   r   rF   r;   r5   r   rF   ZSemaphoreAdapter.statistics  s,    ##+&Q77))++r   )r   r   r   )r   r   r   r   r   r   r6   r   rR   r   r_   rv   rk   r   r   rF   r   Z__classcell__)r   s   @r   r   r     s    ,0)0# !%	#
 ##	$ !%		$
 #	$ 	$ ( (()" % %  , ,r   r   c                  s    ] tR tRtR R ltR R ltR R lt]R R	 l4       t]P                  R
 R l4       t]R R l4       t
]R R l4       tR R ltR R ltR R ltR R ltR R ltR R ltR R ltRtR# ) CapacityLimiteri   c               rU   )r*   r   r   r+   r   r   r,   r-   r   r.   CapacityLimiter.__annotate__  s     8 85 8_ 8r   c                	sn     \        4       P                  V4      #   \         d    \        T4      u # i ; ir0   )r   create_capacity_limiterr	   CapacityLimiterAdapterr4   r   r   r   r6   ZCapacityLimiter.__new__  s5    	8$&>>|LL 	8),77	8s    44c               r(   r7   r   r,   r-   r   r.   r     s     " "$ "r   c                	rB   r0   r:   r;   r5   r   r`   ZCapacityLimiter.__aenter__  s     !!rD   c               rc   rd   r   r,   r-   r   r.   r   
  s2     " "," &" %	"
 
"r   c                	rB   r0   r:   rl   rm   r   rn   ZCapacityLimiter.__aexit__
        "!rD   c               r(   r*   r+   r   r   r,   r-   r   r.   r     s     " "e "r   c                r9   )aQ  
The total number of tokens available for borrowing.

This is a read-write property. If the total number of tokens is increased, the
proportionate number of tasks waiting on this limiter will be granted their
tokens.

.. versionchanged:: 3.0
    The property is now writable.
.. versionchanged:: 4.12
    The value can now be set to 0.

r:   r;   r5   r   r   CapacityLimiter.total_tokens  s
     "!r   c               rU   r*   r   r   r+   r8   r   r,   r-   r   r.   r   $  s     " "% "D "r   c                	r9   r0   r:   r<   r   r   r   r   r   #  r>   r   c               r(   r   r   r,   r-   r   r.   r   (  s     " " "r   c                r9   )z7The number of tokens that have currently been borrowed.r:   r;   r5   r   r   ZCapacityLimiter.borrowed_tokens'  r   r   c               r(   r   r   r,   r-   r   r.   r   -  s     " "% "r   c                r9   )z7The number of tokens currently available to be borrowedr:   r;   r5   r   available_tokensZ CapacityLimiter.available_tokens,  r   r   c               r(   r7   r   r,   r-   r   r.   r   1  s     " " "r   c                r9   )z
Acquire a token for the current task without waiting for one to become
available.

:raises ~anyio.WouldBlock: if there are no tokens available for borrowing

r:   r;   r5   r   rv   ZCapacityLimiter.acquire_nowait1  
     "!r   c               rU   r*   borrowerrL   r+   r8   r   r,   r-   r   r.   r   ;  s     " "F "t "r   c                r9   )z
Acquire a token without waiting for one to become available.

:param borrower: the entity borrowing a token
:raises ~anyio.WouldBlock: if there are no tokens available for borrowing

r:   r<   r   r   r   acquire_on_behalf_of_nowaitZ+CapacityLimiter.acquire_on_behalf_of_nowait;  r   r   c               r(   r7   r   r,   r-   r   r.   r   E  s     " "t "r   c                rB   )zZ
Acquire a token for the current task, waiting if necessary for one to become
available.

r:   r;   r5   r   r_   ZCapacityLimiter.acquireE  r   rD   c               rU   r   r   r,   r-   r   r.   r   M  s     " "6 "d "r   c                rB   )zt
Acquire a token, waiting if necessary for one to become available.

:param borrower: the entity borrowing a token

r:   r   r   r   acquire_on_behalf_ofZ$CapacityLimiter.acquire_on_behalf_ofM  s      "!rD   c               r(   r7   r   r,   r-   r   r.   r   V  s     " " "r   c                r9   )z
Release the token held by the current task.

:raises RuntimeError: if the current task has not borrowed a token from this
    limiter.

r:   r;   r5   r   rk   ZCapacityLimiter.releaseV  r   r   c               rU   r   r   r,   r-   r   r.   r   `  s     " "V " "r   c                r9   )z
Release the token held by the given borrower.

:raises RuntimeError: if the borrower has not borrowed a token from this
    limiter.

r:   r   r   r   release_on_behalf_ofZ$CapacityLimiter.release_on_behalf_of`  r   r   c               r(   r*   r+   r   r   r,   r-   r   r.   r   j  s     " "5 "r   c                r9   )zT
Return statistics about the current state of this limiter.

.. versionadded:: 3.0

r:   r;   r5   r   rF   ZCapacityLimiter.statisticsj  rw   r   r   N)r   r   r   r   r6   r`   rn   rR   r   setterr   r   rv   r   r_   r   rk   r   rF   r   r   r   r   r   r      s    8"" " "  " " " " " """""""" "r   r   c                  s,   ] tR tRt$ RtR]R&   R R ltR R lt]R	 R
 l4       t	R R lt
R R lt]R R l4       t]P                  R R l4       t]R R l4       t]R R l4       tR R ltR R ltR R ltR R ltR R  ltR! R" ltR# R$ ltR%tR# )&r   it  NzCapacityLimiter | None_internal_limiterc               rU   )r*   r   r   r+   r   r   r,   r-   r   r.   #CapacityLimiterAdapter.__annotate__w  s     # #5 #-C #r   c                	rJ   r0   rK   r   r   r   r6   ZCapacityLimiterAdapter.__new__w  rM   r   c               rU   )r*   r   r   r+   r8   r   r,   r-   r   r.   r   z  s     ) )U )t )r   c                	r   r0   )r   )r<   r   r   r   r   ZCapacityLimiterAdapter.__init__z  s    (r   c               r(   )r*   r+   r   r   r,   r-   r   r.   r   ~  s     & &/ &r   c                	s    V P                   f)   \        4       P                  V P                  4      V n         V P                   # r0   )r   r   r   _total_tokensr;   r5   r   _limiterZCapacityLimiterAdapter._limiter}  s;    !!)%6%8%P%P""&D" %%%r   c               r(   r7   r   r,   r-   r   r.   r     s     ) )$ )r   c                	rO   r0   )r   r`   r;   r5   r   r`   Z!CapacityLimiterAdapter.__aenter__  s     mm&&(((rP   c               rc   rd   r   r,   r-   r   r.   r     s8     H H,H &H %	H
 
Hr   c                	sV   "   V P                   P                  WV4      G R j  xL
 #  L5ir0   )r   rn   rl   rm   r   rn   Z CapacityLimiterAdapter.__aexit__  s$      ]],,XGGGGs    )')c               r(   r   r   r,   r-   r   r.   r     s     3 3e 3r   c                	b    V P                   f   V P                  # V P                   P                  # r0   r   r   r   r;   r5   r   r   #CapacityLimiterAdapter.total_tokens  s,    !!)%%%%%222r   c               rU   r   r   r,   r-   r   r.   r     s     
+ 
+% 
+D 
+r   c                	s    \        V\        4      '       g    V\        P                  Jd   \	        R 4      hV^8  d   \        R4      hV P                  f	   Wn        R# WP                  n	        R# )z'total_tokens must be an int or math.infztotal_tokens must be >= 1N)
r   r   mathZinfr   r   r   r   r   r   r   r   r   r   r     sX    %%%%txx*?EFFQY899!!)!&%*"r   c               r(   r   r   r,   r-   r   r.   r     s     6 6 6r   c                	sN    V P                   f   ^ # V P                   P                  # r0   )r   r   r;   r5   r   r   Z&CapacityLimiterAdapter.borrowed_tokens  s#    !!)%%555r   c               r(   r   r   r,   r-   r   r.   r     s     7 7% 7r   c                	r   r0   )r   r   r   r;   r5   r   r   Z'CapacityLimiterAdapter.available_tokens  s,    !!)%%%%%666r   c               r(   r7   r   r,   r-   r   r.   r     s     ' ' 'r   c                	r   r0   )r   rv   r;   r5   r   rv   Z%CapacityLimiterAdapter.acquire_nowait  s    $$&r   c               rU   r   r   r,   r-   r   r.   r     s     < <F <t <r   c                	<    V P                   P                  V4       R # r0   )r   r   r   r   r   r   Z2CapacityLimiterAdapter.acquire_on_behalf_of_nowait  s    11(;r   c               r(   r7   r   r,   r-   r   r.   r     s     & &t &r   c                	rO   r0   )r   r_   r;   r5   r   r_   ZCapacityLimiterAdapter.acquire  s     mm##%%%rP   c               rU   r   r   r,   r-   r   r.   r     s     ; ;6 ;d ;r   c                	sX   "   V P                   P                  V4      G R j  xL
  R #  L5ir0   )r   r   r   r   r   r   Z+CapacityLimiterAdapter.acquire_on_behalf_of  s     mm00:::s   *(*c               r(   r7   r   r,   r-   r   r.   r     s          r   c                	r   r0   )r   rk   r;   r5   r   rk   ZCapacityLimiterAdapter.release  s    r   c               rU   r   r   r,   r-   r   r.   r     s     5 5V 5 5r   c                	r   r0   )r   r   r   r   r   r   Z+CapacityLimiterAdapter.release_on_behalf_of  s    **84r   c               r(   r   r   r,   r-   r   r.   r     s     	3 	35 	3r   c                	s    V P                   f   \        ^ V P                  R^ R7      # V P                   P                  4       # )N)r   r   r    r   r   )r   r   r   rF   r;   r5   r   rF   Z!CapacityLimiterAdapter.statistics  sD    !!), !!..	  %%0022r   r   )r   r   r   r   r   r   r6   r   rR   r   r`   rn   r   r   r   r   rv   r   r_   r   rk   r   rF   r   r   r   r   r   r   t  s    04-4#) & &)H 3 3 
+ 
+ 6 6 7 7'<&; 5	3 	3r   r   c                  sF    ] tR tRtRtRtRR R lltR R ltR R ltR	t	R
# )ResourceGuardi  a  
A context manager for ensuring that a resource is only used by a single task at a
time.

Entering this context manager while the previous has not exited it yet will trigger
:exc:`BusyResourceError`.

:param action: the action to guard against (visible in the :exc:`BusyResourceError`
    when triggered, e.g. "Another task is already {action} this resource")

.. versionadded:: 4.1
c               r(   )r*   actionZstrr   r,   r-   r   r.   ResourceGuard.__annotate__  s      s r   c                	s     Wn         R V n        R# FNr   _guarded)r<   r   r   r   r   ZResourceGuard.__init__  s    !r   c               r(   r7   r   r,   r-   r   r.   r     s      4 r   c                	sb    V P                   '       d   \        V P                  4      hR V n         R# )TN)r   r   r   r;   r5   r   	__enter__ZResourceGuard.__enter__  s!    ===#DKK00r   c               rc   rd   r   r,   r-   r   r.   r     s2      , & %	
 
r   c                	s    R V n         R# r   )r   rl   rm   r   __exit__ZResourceGuard.__exit__  s     r   )r   r   Nr   )Zusing)
r   r   r   r   r   Z	__slots__r   r   r   r   r   r   r   r   r     s"     %I r   r   ))Z
__future__r    r   Zcollectionsr   Zcollections.abcr   Zdataclassesr   Ztypesr   Ztypingr   Zlowlevelr   Z
_eventloopr   Z_exceptionsr   r	   Z_tasksr
   Z_testingr   r   r   r   r   r!   r%   r&   r'   r2   rS   rY   r   r   r   r   r   r   r   r   r   <module>r      sF   "   $ !   . ) <  0CL $   $  " $
 
 
 $$ $ $ $  " "<#15 #1L-" -"`=0$ =0@hP hPVQ" Q"h8,y 8,vq" q"hZ3_ Z3z   r   