
    ܈hzQ                    >   S SK Jr  S SKrS SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  S	S
KJr  SSKJr  SSKJr  SSKJr  SSKJrJr  \" S5      r\" SS9 " S S5      5       r\" SS9 " S S5      5       r\" SS9 " S S5      5       r\" SS9 " S S5      5       r\" SS9 " S S5      5       r " S S5      r  " S S \ 5      r! " S! S"5      r" " S# S$\"5      r# " S% S&5      r$ " S' S(5      r% " S) S*\%5      r& " S+ S,5      r' " S- S.\'5      r( " S/ S05      r)g)1    )annotationsN)deque)Callable)	dataclass)TracebackType)TypeVar)AsyncLibraryNotFoundError   )checkpoint_if_cancelled   )get_async_backend)BusyResourceError)CancelScope)TaskInfoget_current_taskTT)frozenc                  $    \ rS rSr% SrS\S'   Srg)EventStatistics   zJ
: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       DD:\TimeStamps\venv\Lib\site-packages\anyio/_core/_synchronization.pyr   r      s     r"   r   c                  B    \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S
rg)CapacityLimiterStatistics   az  
: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                  8    \ rS rSr% SrS\S'   S\S'   S\S'   S	rg
)LockStatistics0   a   
: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 | Noneownerr   r   r   Nr   r   r"   r#   r,   r,   0   s     Lr"   r,   c                  .    \ rS rSr% SrS\S'   S\S'   Srg)	ConditionStatistics>   z
: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,   lock_statisticsr   Nr   r   r"   r#   r3   r3   >   s     ##r"   r3   c                  $    \ rS rSr% SrS\S'   Srg)SemaphoreStatisticsJ   zR
:ivar int tasks_waiting: number of tasks waiting on :meth:`~.Semaphore.acquire`

r   r   r   Nr   r   r"   r#   r7   r7   J   s    
 r"   r7   c                  F    \ rS rSrS	S jrS
S jrSS jrS
S jrSS jrSr	g)EventT   c                h     [        5       R                  5       $ ! [         a    [        5       s $ f = fN)r   create_eventr	   EventAdapterclss    r#   __new__Event.__new__U   s0    	"$&3355( 	">!	"s    11c                    [         e)z&Set the flag, notifying all listeners.NotImplementedErrorselfs    r#   set	Event.set[       !!r"   c                    [         e)z5Return ``True`` if the flag is set, ``False`` if not.rE   rG   s    r#   is_setEvent.is_set_   rK   r"   c                   #    [         e7f)zz
Wait until the flag has been set.

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

rE   rG   s    r#   wait
Event.waitc   s      "!   	c                    [         e)z8Return statistics about the current state of this event.rE   rG   s    r#   
statisticsEvent.statisticsm   rK   r"   r   Nreturnr:   rW   NonerW   r.   rW   r   )
r   r   r   r   rB   rI   rM   rP   rT   r!   r   r"   r#   r:   r:   T   s    """""r"   r:   c                  x    \ rS rSr% SrS\S'   SrS\S'   SS jr\SS	 j5       r	SS
 jr
SS jrSS jrSS jrSrg)r?   r   NzEvent | None_internal_eventFr.   _is_setc                ,    [         R                  U 5      $ r=   objectrB   r@   s    r#   rB   EventAdapter.__new__v       ~~c""r"   c                    U R                   cH  [        5       R                  5       U l         U R                  (       a  U R                   R	                  5         U R                   $ r=   )r^   r   r>   r_   rI   rG   s    r#   _eventEventAdapter._eventy   sG    '#4#6#C#C#ED ||$$((*###r"   c                b    U R                   c  SU l        g U R                  R                  5         g NT)r^   r_   rf   rI   rG   s    r#   rI   EventAdapter.set   s#    'DLKKOOr"   c                h    U R                   c  U R                  $ U R                   R                  5       $ r=   )r^   r_   rM   rG   s    r#   rM   EventAdapter.is_set   s-    '<<##**,,r"   c                T   #    U R                   R                  5       I S h  vN   g  N7fr=   )rf   rP   rG   s    r#   rP   EventAdapter.wait   s     kk      (&(c                b    U R                   c	  [        SS9$ U R                   R                  5       $ Nr   )r   )r^   r   rT   rG   s    r#   rT   EventAdapter.statistics   s.    '"33##..00r"   )r^   r_   )rW   r?   rV   rX   rZ   r[   )r   r   r   r   r^   r    r_   rB   propertyrf   rI   rM   rP   rT   r!   r   r"   r#   r?   r?   r   sC    $(O\(GT# $ $-!1r"   r?   c                  |    \ rS rSrS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)Lock   Ffast_acquirec               d     [        5       R                  US9$ ! [         a    [        US9s $ f = fNrw   )r   create_lockr	   LockAdapterrA   rx   s     r#   rB   Lock.__new__   s8    	:$&222MM( 	:L99	:s    //c                @   #    U R                  5       I S h  vN   g  N7fr=   acquirerG   s    r#   
__aenter__Lock.__aenter__        lln   c                ,   #    U R                  5         g 7fr=   releaserH   exc_typeexc_valexc_tbs       r#   	__aexit__Lock.__aexit__         	   c                   #    [         e7f)Acquire the lock.rE   rG   s    r#   r   Lock.acquire        !!rR   c                    [         e)_
Acquire the lock, without blocking.

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

rE   rG   s    r#   acquire_nowaitLock.acquire_nowait   
     "!r"   c                    [         e)Release the lock.rE   rG   s    r#   r   Lock.release   rK   r"   c                    [         ez*Return True if the lock is currently held.rE   rG   s    r#   r/   Lock.locked   rK   r"   c                    [         e)zP
Return statistics about the current state of this lock.

.. versionadded:: 3.0
rE   rG   s    r#   rT   Lock.statistics   
     "!r"   r   N)rx   r.   rW   ru   rX   r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | NonerW   rY   rZ   rW   r,   )r   r   r   r   rB   r   r   r   r   r   r/   rT   r!   r   r"   r#   ru   ru      sS    -2 :, & %	
 
"""""r"   ru   c                      \ rS rSr% SrS\S'   SS.SS jjrSS.SS jjr\SS	 j5       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)r|      NLock | None_internal_lockFrw   c               ,    [         R                  U 5      $ r=   ra   r}   s     r#   rB   LockAdapter.__new__   rd   r"   c                   Xl         g r=   _fast_acquire)rH   rx   s     r#   __init__LockAdapter.__init__   s    )r"   c                    U R                   c&  [        5       R                  U R                  S9U l         U R                   $ rz   )r   r   r{   r   rG   s    r#   _lockLockAdapter._lock   sA    &"3"5"A"A!// #B #D """r"   c                T   #    U R                   R                  5       I S h  vN   g  N7fr=   r   r   rG   s    r#   r   LockAdapter.__aenter__   s     jj  """ro   c                \   #    U R                   b  U R                   R                  5         g g 7fr=   )r   r   r   s       r#   r   LockAdapter.__aexit__   s*      *'') +s   *,c                T   #    U R                   R                  5       I Sh  vN   g N7f)r   Nr   rG   s    r#   r   LockAdapter.acquire   s     jj  """ro   c                8    U R                   R                  5         g)r   N)r   r   rG   s    r#   r   LockAdapter.acquire_nowait   s     	

!!#r"   c                8    U R                   R                  5         g)r   Nr   r   rG   s    r#   r   LockAdapter.release       

r"   c                6    U R                   R                  5       $ r   r   r/   rG   s    r#   r/   LockAdapter.locked       zz  ""r"   c                j    U R                   c  [        SSS5      $ U R                   R                  5       $ )zQ
Return statistics about the current state of this lock.

.. versionadded:: 3.0

NFr   )r   r,   rT   rG   s    r#   rT   LockAdapter.statistics   s4     &!%q11""--//r"   )r   r   )rx   r.   rW   r|   )rx   r.   )rW   ru   rX   r   rZ   r   )r   r   r   r   r   r    rB   r   rs   r   r   r   r   r   r   r/   rT   r!   r   r"   r#   r|   r|      s{    "&NK&-2 # 05 * # ##*,* &* %	*
 
*#$#
0r"   r|   c                      \ rS rSr% SrS\S'   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SS jjrSS jrSS jrSS jrSS jrSrg)	Conditioni  Nr0   _owner_taskc                R    U=(       d
    [        5       U l        [        5       U l        g r=   )ru   r   r   _waiters)rH   locks     r#   r   Condition.__init__  s    ^TV
&+gr"   c                @   #    U R                  5       I S h  vN   g  N7fr=   r   rG   s    r#   r   Condition.__aenter__  r   r   c                ,   #    U R                  5         g 7fr=   r   r   s       r#   r   Condition.__aexit__  r   r   c                J    U R                   [        5       :w  a  [        S5      eg )Nz3The current task is not holding the underlying lock)r   r   RuntimeErrorrG   s    r#   _check_acquiredCondition._check_acquired  s%    /11TUU 2r"   c                r   #    U R                   R                  5       I Sh  vN   [        5       U l        g N7f)zAcquire the underlying lock.N)r   r   r   r   rG   s    r#   r   Condition.acquire  s+     jj  """+- 	#s   757c                V    U R                   R                  5         [        5       U l        g)j
Acquire the underlying lock, without blocking.

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

N)r   r   r   r   rG   s    r#   r   Condition.acquire_nowait#  s     	

!!#+-r"   c                8    U R                   R                  5         g)zRelease the underlying lock.Nr   rG   s    r#   r   Condition.release-  r   r"   c                6    U R                   R                  5       $ )zReturn True if the lock is set.r   rG   s    r#   r/   Condition.locked1  r   r"   c                    U R                  5         [        U5       H.  n U R                  R                  5       nUR                  5         M0     g! [         a       gf = f)zNotify exactly n listeners.N)r   ranger   popleft
IndexErrorrI   )rH   n_events       r#   notifyCondition.notify5  sR    qA--/ IIK   s   A
AAc                    U R                  5         U R                   H  nUR                  5         M     U R                  R                  5         g)zNotify all the listeners.N)r   r   rI   clearrH   r   s     r#   
notify_allCondition.notify_all@  s7    ]]EIIK # 	r"   c                p  #    [        5       I Sh  vN   U R                  5         [        5       nU R                  R	                  U5        U R                  5          UR                  5       I Sh  vN    [        SS9   U R                  5       I Sh  vN   SSS5        g N N2! [         a2    UR                  5       (       d  U R                  R                  U5        e f = f NP! , (       d  f       g= f! [        SS9   U R                  5       I Sh  vN    SSS5        f ! , (       d  f       f = f= f7f)zWait for a notification.NT)shield)r   r   r:   r   appendr   rP   BaseExceptionrM   remover   r   r   s     r#   rP   Condition.waitH  s     %'''U#		%**, D)lln$$ *) 	(  	<<>>$$U+		 % *)D)lln$$ *))s   D6BA	D6B# .B!/B# 4	D6=C$C"C$
D6!B# #<CC5 "C$$
C2.D65
D3?D"D
D"	D3"
D0,D33D6c                ~   #    U" 5       =n(       d(  U R                  5       I Sh  vN   U" 5       =n(       d  M(  U$  N7f)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)rP   )rH   	predicateresults      r#   wait_forCondition.wait_forZ  s>      '[(6())+ '[(6(  s   "=;==c                p    [        [        U R                  5      U R                  R	                  5       5      $ )zU
Return statistics about the current state of this condition.

.. versionadded:: 3.0
)r3   lenr   r   rT   rG   s    r#   rT   Condition.statisticsj  s'     #3t}}#5tzz7L7L7NOOr"   )r   r   r   r=   )r   r   rX   r   rZ   )r   )r   r   rW   rY   )r   zCallable[[], T]rW   r   )rW   r3   )r   r   r   r   r   r    r   r   r   r   r   r   r   r/   r   r   rP   r   rT   r!   r   r"   r#   r   r     su    #'K'., & %	
 
V.
.#	%$ Pr"   r   c                      \ rS rSrSSS.       SS jjrSS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5       r\SS j5       rSS jrSrg)	Semaphoreis  NF	max_valuerx   c               f     [        5       R                  XUS9$ ! [         a    [        XS9s $ f = f)Nr   r   )r   create_semaphorer	   SemaphoreAdapterrA   initial_valuer   rx   s       r#   rB   Semaphore.__new__t  sF    	H$&77 8   ) 	H#MGG	Hs    00c                   [        U[        5      (       d  [        S5      eUS:  a  [        S5      eUb0  [        U[        5      (       d  [        S5      eX!:  a  [        S5      eX0l        g )Nz initial_value must be an integerr   zinitial_value must be >= 0z$max_value must be an integer or Nonez7max_value must be equal to or higher than initial_value)
isinstancer   	TypeError
ValueErrorr   )rH   r  r   rx   s       r#   r   Semaphore.__init__  sn     --->??19:: i-- FGG( M  *r"   c                B   #    U R                  5       I S h  vN   U $  N7fr=   r   rG   s    r#   r   Semaphore.__aenter__  s     lln 	s   c                ,   #    U R                  5         g 7fr=   r   r   s       r#   r   Semaphore.__aexit__  r   r   c                   #    [         e7f)z5Decrement the semaphore value, blocking if necessary.rE   rG   s    r#   r   Semaphore.acquire  r   rR   c                    [         e)r   rE   rG   s    r#   r   Semaphore.acquire_nowait  r   r"   c                    [         e)zIncrement the semaphore value.rE   rG   s    r#   r   Semaphore.release  rK   r"   c                    [         e)z#The current value of the semaphore.rE   rG   s    r#   valueSemaphore.value  
     "!r"   c                    [         e)z#The maximum value of the semaphore.rE   rG   s    r#   r   Semaphore.max_value  r  r"   c                    [         e)zU
Return statistics about the current state of this semaphore.

.. versionadded:: 3.0
rE   rG   s    r#   rT   Semaphore.statistics  r   r"   r   )r  r   r   
int | Nonerx   r.   rW   r   )r  r   r   r  rx   r.   rW   r   r   rX   rW   r   rW   r  rW   r7   )r   r   r   r   rB   r   r   r   r   r   r   rs   r  r   rT   r!   r   r"   r#   r   r   s  s    
 !%"HH 	H
 H 
H$ !%"** 	*
 **, & %	
 
""" " " " ""r"   r   c                     ^  \ rS rSr% SrS\S'   SSS.       SS jjrSSS.       SU 4S jjjr\SS	 j5       r	SS
 jr
SS jrSS jr\SS j5       r\SS j5       rSS jrSrU =r$ )r  i  NzSemaphore | None_internal_semaphoreFr   c               ,    [         R                  U 5      $ r=   ra   r  s       r#   rB   SemaphoreAdapter.__new__  s     ~~c""r"   c               :   > [         TU ]  XUS9  Xl        X l        g )Nr   )superr   _initial_value
_max_value)rH   r  r   rx   	__class__s       r#   r   SemaphoreAdapter.__init__  s"     	,W+#r"   c                    U R                   c1  [        5       R                  U R                  U R                  S9U l         U R                   $ )Nr   )r"  r   r   r'  r(  rG   s    r#   
_semaphoreSemaphoreAdapter._semaphore  sG    ##+'8':'K'K##t (L (D$ '''r"   c                T   #    U R                   R                  5       I S h  vN   g  N7fr=   )r,  r   rG   s    r#   r   SemaphoreAdapter.acquire  s     oo%%'''ro   c                8    U R                   R                  5         g r=   )r,  r   rG   s    r#   r   SemaphoreAdapter.acquire_nowait  s    &&(r"   c                8    U R                   R                  5         g r=   )r,  r   rG   s    r#   r   SemaphoreAdapter.release  s    !r"   c                `    U R                   c  U R                  $ U R                  R                  $ r=   )r"  r'  r,  r  rG   s    r#   r  SemaphoreAdapter.value  s*    ##+&&&$$$r"   c                    U R                   $ r=   )r(  rG   s    r#   r   SemaphoreAdapter.max_value  s    r"   c                b    U R                   c	  [        SS9$ U R                  R                  5       $ rq   )r"  r7   r,  rT   rG   s    r#   rT   SemaphoreAdapter.statistics  s,    ##+&Q77))++r"   )r'  r"  r(  )r  r   r   r  rx   r.   rW   r  )r  r   r   r  rx   r.   rW   rY   r  rX   r  r  r   )r   r   r   r   r"  r    rB   r   rs   r,  r   r   r   r  r   rT   r!   __classcell__)r)  s   @r#   r  r    s    ,0)0 !%"## 	#
 # 
# !%"	$	$ 		$
 	$ 
	$ 	$ ( (()" % %  , ,r"   r  c                      \ rS rSrSS jrSS jr        SS jr\SS j5       r\R                  SS j5       r\SS j5       r
\SS j5       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)CapacityLimiteri  c                l     [        5       R                  U5      $ ! [         a    [        U5      s $ f = fr=   )r   create_capacity_limiterr	   CapacityLimiterAdapterrA   r)   s     r#   rB   CapacityLimiter.__new__  s5    	8$&>>|LL( 	8),77	8s    33c                   #    [         e7fr=   rE   rG   s    r#   r   CapacityLimiter.__aenter__	  s     !!rR   c                   #    [         e7fr=   rE   r   s       r#   r   CapacityLimiter.__aexit__        "!rR   c                    [         e)a  
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.

rE   rG   s    r#   r)   CapacityLimiter.total_tokens  s
     "!r"   c                    [         er=   rE   rH   r  s     r#   r)   rH  #  rK   r"   c                    [         e)z7The number of tokens that have currently been borrowed.rE   rG   s    r#   r'   CapacityLimiter.borrowed_tokens'  r  r"   c                    [         e)z7The number of tokens currently available to be borrowedrE   rG   s    r#   available_tokens CapacityLimiter.available_tokens,  r  r"   c                    [         e)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

rE   rG   s    r#   r   CapacityLimiter.acquire_nowait1  
     "!r"   c                    [         e)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

rE   rH   borrowers     r#   acquire_on_behalf_of_nowait+CapacityLimiter.acquire_on_behalf_of_nowait;  rR  r"   c                   #    [         e7f)zZ
Acquire a token for the current task, waiting if necessary for one to become
available.

rE   rG   s    r#   r   CapacityLimiter.acquireE  rF  rR   c                   #    [         e7f)zt
Acquire a token, waiting if necessary for one to become available.

:param borrower: the entity borrowing a token

rE   rT  s     r#   acquire_on_behalf_of$CapacityLimiter.acquire_on_behalf_ofM  s      "!rR   c                    [         e)z
Release the token held by the current task.

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

rE   rG   s    r#   r   CapacityLimiter.releaseV  rR  r"   c                    [         e)z
Release the token held by the given borrower.

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

rE   rT  s     r#   release_on_behalf_of$CapacityLimiter.release_on_behalf_of`  rR  r"   c                    [         e)zT
Return statistics about the current state of this limiter.

.. versionadded:: 3.0

rE   rG   s    r#   rT   CapacityLimiter.statisticsj  r   r"   r   N)r)   r(   rW   r<  rX   r   rW   r(   r  r(   rW   rY   r  rU  rb   rW   rY   rW   r%   )r   r   r   r   rB   r   r   rs   r)   setterr'   rN  r   rV  r   r[  r   r`  rT   r!   r   r"   r#   r<  r<    s    8""," &" %	"
 
" " " " " " " " """"""""r"   r<  c                     \ rS rSr% SrS\S'   SS jrSS jr\SS j5       r	SS jr
        SS	 jr\SS
 j5       r\R                  SS j5       r\SS j5       r\SS j5       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) r?  it  NzCapacityLimiter | None_internal_limiterc                ,    [         R                  U 5      $ r=   ra   r@  s     r#   rB   CapacityLimiterAdapter.__new__w  rd   r"   c                    Xl         g r=   )r)   )rH   r)   s     r#   r   CapacityLimiterAdapter.__init__z  s    (r"   c                    U R                   c(  [        5       R                  U R                  5      U l         U R                   $ r=   )rj  r   r>  _total_tokensrG   s    r#   _limiterCapacityLimiterAdapter._limiter}  s;    !!)%6%8%P%P""&D" %%%r"   c                T   #    U R                   R                  5       I S h  vN   g  N7fr=   )rq  r   rG   s    r#   r   !CapacityLimiterAdapter.__aenter__  s     mm&&(((ro   c                V   #    U R                   R                  XU5      I S h  vN $  N7fr=   )rq  r   r   s       r#   r    CapacityLimiterAdapter.__aexit__  s$      ]],,XGGGGs    )')c                `    U R                   c  U R                  $ U R                   R                  $ r=   rj  rp  r)   rG   s    r#   r)   #CapacityLimiterAdapter.total_tokens  s,    !!)%%%%%222r"   c                    [        U[        5      (       d  U[        R                  La  [	        S5      eUS:  a  [        S5      eU R                  c  Xl        g XR                  l	        g )Nz'total_tokens must be an int or math.infr   ztotal_tokens must be >= 1)
r  r   mathinfr  r  rj  rp  rq  r)   rJ  s     r#   r)   ry    sX    %%%%txx*?EFFQY899!!)!&%*"r"   c                J    U R                   c  gU R                   R                  $ )Nr   )rj  r'   rG   s    r#   r'   &CapacityLimiterAdapter.borrowed_tokens  s#    !!)%%555r"   c                `    U R                   c  U R                  $ U R                   R                  $ r=   )rj  rp  rN  rG   s    r#   rN  'CapacityLimiterAdapter.available_tokens  s,    !!)%%%%%666r"   c                8    U R                   R                  5         g r=   )rq  r   rG   s    r#   r   %CapacityLimiterAdapter.acquire_nowait  s    $$&r"   c                :    U R                   R                  U5        g r=   )rq  rV  rT  s     r#   rV  2CapacityLimiterAdapter.acquire_on_behalf_of_nowait  s    11(;r"   c                T   #    U R                   R                  5       I S h  vN   g  N7fr=   )rq  r   rG   s    r#   r   CapacityLimiterAdapter.acquire  s     mm##%%%ro   c                V   #    U R                   R                  U5      I S h  vN   g  N7fr=   )rq  r[  rT  s     r#   r[  +CapacityLimiterAdapter.acquire_on_behalf_of  s     mm00:::s   )')c                8    U R                   R                  5         g r=   )rq  r   rG   s    r#   r   CapacityLimiterAdapter.release  s    r"   c                :    U R                   R                  U5        g r=   )rq  r`  rT  s     r#   r`  +CapacityLimiterAdapter.release_on_behalf_of  s    **84r"   c                |    U R                   c  [        SU R                  SSS9$ U R                   R                  5       $ )Nr   r   )r'   r)   r*   r   )rj  r%   r)   rT   rG   s    r#   rT   !CapacityLimiterAdapter.statistics  sD    !!), !!..	  %%0022r"   rx  )r)   r(   rW   r?  )r)   r(   rW   rY   )rW   r<  rX   r   rd  re  r  rf  rg  )r   r   r   r   rj  r    rB   r   rs   rq  r   r   r)   rh  r'   rN  r   rV  r   r[  r   r`  rT   r!   r   r"   r#   r?  r?  t  s    04-4#) & &)H,H &H %	H
 
H 3 3 
+ 
+ 6 6 7 7'<&; 5	3r"   r?  c                  N    \ rS rSrSrSrS	S
S jjrSS jr        SS jrSr	g)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
action_guardedc                    Xl         SU l        g NFr  )rH   r  s     r#   r   ResourceGuard.__init__  s    !r"   c                ^    U R                   (       a  [        U R                  5      eSU l         g ri   )r  r   r  rG   s    r#   	__enter__ResourceGuard.__enter__  s    ==#DKK00r"   c                    SU l         g r  )r  r   s       r#   __exit__ResourceGuard.__exit__  s     r"   )r  r  N)using)r  strrX   r   )
r   r   r   r   r   	__slots__r   r  r  r!   r   r"   r#   r  r    sC     %I, & %	
 
r"   r  )*
__future__r   r{  collectionsr   collections.abcr   dataclassesr   typesr   typingr   sniffior	   lowlevelr   
_eventloopr   _exceptionsr   _tasksr   _testingr   r   r   r   r%   r,   r3   r7   r:   r?   ru   r|   r   r   r  r<  r?  r  r   r"   r#   <module>r     sI   "   $ !   - . ) *  0CL $   $  " $
 
 
 $$ $ $ $  " "<#15 #1L-" -"`=0$ =0@hP hPVQ" Q"h8,y 8,vo" o"dZ3_ Z3z   r"   