
    hzQ                    \   d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d	d
lmZ ddlmZ ddlmZ ddlmZ ddlmZmZ  ed      Z ed       G d d             Z ed       G d d             Z ed       G d d             Z ed       G d d             Z ed       G d d             Z G d d      Z  G d d e       Z! G d! d"      Z" G d# d$e"      Z# G d% d&      Z$ G d' d(      Z% G d) d*e%      Z& G d+ d,      Z' G d- d.e'      Z( G d/ d0      Z)y)1    )annotationsN)deque)Callable)	dataclass)TracebackType)TypeVar)AsyncLibraryNotFoundError   )checkpoint_if_cancelled   )get_async_backend)BusyResourceError)CancelScope)TaskInfoget_current_taskTT)frozenc                      e Zd ZU dZded<   y)EventStatisticszR
    :ivar int tasks_waiting: number of tasks waiting on :meth:`~.Event.wait`
    inttasks_waitingN__name__
__module____qualname____doc____annotations__     AD:\jyotish\venv\Lib\site-packages\anyio/_core/_synchronization.pyr   r      s     r   r   c                  :    e Zd ZU dZded<   ded<   ded<   ded<   y	)
CapacityLimiterStatisticsa  
    :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   Nr   r   r   r    r"   r"      s!     !!r   r"   c                  0    e Zd ZU dZded<   ded<   ded<   y)	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 | Noneownerr   r   Nr   r   r   r    r(   r(   0   s     Lr   r(   c                  &    e Zd ZU dZded<   ded<   y)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(   lock_statisticsNr   r   r   r    r.   r.   >   s     ##r   r.   c                      e Zd ZU dZded<   y)SemaphoreStatisticszZ
    :ivar int tasks_waiting: number of tasks waiting on :meth:`~.Semaphore.acquire`

    r   r   Nr   r   r   r    r1   r1   J   s    
 r   r1   c                  4    e Zd ZddZddZd	dZddZd
dZy)Eventc                f    	 t               j                         S # t        $ r t               cY S w xY wN)r   create_eventr	   EventAdapterclss    r    __new__zEvent.__new__U   s0    	"$&3355( 	">!	"s    00c                    t         )z&Set the flag, notifying all listeners.NotImplementedErrorselfs    r    setz	Event.set[       !!r   c                    t         )z5Return ``True`` if the flag is set, ``False`` if not.r<   r>   s    r    is_setzEvent.is_set_   rA   r   c                   K   t         w)z
        Wait until the flag has been set.

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

        r<   r>   s    r    waitz
Event.waitc   s      "!   	c                    t         )z8Return statistics about the current state of this event.r<   r>   s    r    
statisticszEvent.statisticsm   rA   r   Nreturnr3   rJ   NonerJ   r)   rJ   r   )r   r   r   r:   r@   rC   rE   rH   r   r   r    r3   r3   T   s    """""r   r3   c                  d    e Zd ZU dZded<   dZded<   ddZedd       Zdd	Z	dd
Z
ddZddZy)r7   NzEvent | None_internal_eventFr)   _is_setc                ,    t         j                  |       S r5   objectr:   r8   s    r    r:   zEventAdapter.__new__v       ~~c""r   c                    | j                   Ct               j                         | _         | j                  r| j                   j	                          | j                   S r5   )rP   r   r6   rQ   r@   r>   s    r    _eventzEventAdapter._eventy   sG    '#4#6#C#C#ED ||$$((*###r   c                `    | j                   d| _        y | j                  j                          y NT)rP   rQ   rW   r@   r>   s    r    r@   zEventAdapter.set   s#    'DLKKOOr   c                f    | j                   | j                  S | j                   j                         S r5   )rP   rQ   rC   r>   s    r    rC   zEventAdapter.is_set   s-    '<<##**,,r   c                T   K   | j                   j                          d {    y 7 wr5   )rW   rE   r>   s    r    rE   zEventAdapter.wait   s     kk      (&(c                f    | j                   t        d      S | j                   j                         S Nr   )r   )rP   r   rH   r>   s    r    rH   zEventAdapter.statistics   s.    '"33##..00r   )rJ   r7   rI   rK   rM   rN   )r   r   r   rP   r   rQ   r:   propertyrW   r@   rC   rE   rH   r   r   r    r7   r7   r   sC    $(O\(GT# $ $-!1r   r7   c                  b    e Zd ZddddZddZ	 	 	 	 	 	 	 	 ddZddZddZddZdd	Z	dd
Z
y)LockFfast_acquirec               n    	 t               j                  |      S # t        $ r t        |      cY S w xY wNrb   )r   create_lockr	   LockAdapterr9   rc   s     r    r:   zLock.__new__   s8    	:$&222MM( 	:L99	:s    44c                @   K   | j                          d {    y 7 wr5   acquirer>   s    r    
__aenter__zLock.__aenter__        lln   c                ,   K   | j                          y wr5   releaser?   exc_typeexc_valexc_tbs       r    	__aexit__zLock.__aexit__         	   c                   K   t         w)Acquire the lock.r<   r>   s    r    rk   zLock.acquire        !!rF   c                    t         )w
        Acquire the lock, without blocking.

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

        r<   r>   s    r    acquire_nowaitzLock.acquire_nowait   
     "!r   c                    t         )Release the lock.r<   r>   s    r    rq   zLock.release   rA   r   c                    t         z*Return True if the lock is currently held.r<   r>   s    r    r*   zLock.locked   rA   r   c                    t         )zh
        Return statistics about the current state of this lock.

        .. versionadded:: 3.0
        r<   r>   s    r    rH   zLock.statistics   
     "!r   N)rc   r)   rJ   ra   rK   rs   ztype[BaseException] | Nonert   zBaseException | Noneru   zTracebackType | NonerJ   rL   rM   rJ   r(   )r   r   r   r:   rl   rv   rk   r~   rq   r*   rH   r   r   r    ra   ra      sS    -2 :, & %	
 
"""""r   ra   c                      e Zd ZU dZded<   ddddZddddZedd       Zdd	Z		 	 	 	 	 	 	 	 dd
Z
ddZddZddZddZddZy)rg   NLock | None_internal_lockFrb   c               ,    t         j                  |       S r5   rS   rh   s     r    r:   zLockAdapter.__new__   rU   r   c                   || _         y r5   )_fast_acquire)r?   rc   s     r    __init__zLockAdapter.__init__   s
    )r   c                    | j                   )t               j                  | j                        | _         | j                   S re   )r   r   rf   r   r>   s    r    _lockzLockAdapter._lock   sA    &"3"5"A"A!// #B #D """r   c                T   K   | j                   j                          d {    y 7 wr5   r   rk   r>   s    r    rl   zLockAdapter.__aenter__   s     jj  """r\   c                Z   K   | j                   | j                   j                          y y wr5   )r   rq   rr   s       r    rv   zLockAdapter.__aexit__   s+      *'') +s   )+c                T   K   | j                   j                          d{    y7 w)rz   Nr   r>   s    r    rk   zLockAdapter.acquire   s     jj  """r\   c                8    | j                   j                          y)r}   N)r   r~   r>   s    r    r~   zLockAdapter.acquire_nowait   s     	

!!#r   c                8    | j                   j                          y)r   Nr   rq   r>   s    r    rq   zLockAdapter.release       

r   c                6    | j                   j                         S r   r   r*   r>   s    r    r*   zLockAdapter.locked       zz  ""r   c                h    | j                   t        ddd      S | j                   j                         S )zi
        Return statistics about the current state of this lock.

        .. versionadded:: 3.0

        NFr   )r   r(   rH   r>   s    r    rH   zLockAdapter.statistics   s4     &!%q11""--//r   )rc   r)   rJ   rg   )rc   r)   )rJ   ra   rK   r   rM   r   )r   r   r   r   r   r:   r   r_   r   rl   rv   rk   r~   rq   r*   rH   r   r   r    rg   rg      s{    "&NK&-2 # 05 * # ##*,* &* %	*
 
*#$#
0r   rg   c                      e Zd ZU dZded<   dddZddZ	 	 	 	 	 	 	 	 ddZddZddZ	dd	Z
dd
ZddZdddZddZddZddZddZy)	ConditionNr+   _owner_taskc                H    |xs
 t               | _        t               | _        y r5   )ra   r   r   _waiters)r?   locks     r    r   zCondition.__init__  s    ^TV
&+gr   c                @   K   | j                          d {    y 7 wr5   rj   r>   s    r    rl   zCondition.__aenter__  rm   rn   c                ,   K   | j                          y wr5   rp   rr   s       r    rv   zCondition.__aexit__  rw   rx   c                H    | j                   t               k7  rt        d      y )Nz3The current task is not holding the underlying lock)r   r   RuntimeErrorr>   s    r    _check_acquiredzCondition._check_acquired  s%    /11TUU 2r   c                r   K   | j                   j                          d{    t               | _        y7 w)zAcquire the underlying lock.N)r   rk   r   r   r>   s    r    rk   zCondition.acquire  s,     jj  """+- 	#s   757c                V    | j                   j                          t               | _        y)
        Acquire the underlying lock, without blocking.

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

        N)r   r~   r   r   r>   s    r    r~   zCondition.acquire_nowait#  s     	

!!#+-r   c                8    | j                   j                          y)zRelease the underlying lock.Nr   r>   s    r    rq   zCondition.release-  r   r   c                6    | j                   j                         S )zReturn True if the lock is set.r   r>   s    r    r*   zCondition.locked1  r   r   c                    | j                          t        |      D ]-  }	 | j                  j                         }|j                          / y# t        $ r Y  yw xY w)zNotify exactly n listeners.N)r   ranger   popleft
IndexErrorr@   )r?   n_events       r    notifyzCondition.notify5  sR    qA--/ IIK   s   A	AAc                    | j                          | j                  D ]  }|j                           | j                  j                          y)zNotify all the listeners.N)r   r   r@   clearr?   r   s     r    
notify_allzCondition.notify_all@  s7    ]]EIIK # 	r   c                \  K   t                d{    | j                          t               }| j                  j	                  |       | j                          	 |j                          d{    	 t        d      5  | j                          d{    ddd       y7 7 5# t        $ r- |j                         s| j                  j                  |        w xY w7 J# 1 sw Y   yxY w# t        d      5  | j                          d{  7   ddd       w # 1 sw Y   w xY wxY ww)zWait for a notification.NT)shield)r   r   r3   r   appendrq   rE   BaseExceptionrC   remover   rk   r   s     r    rE   zCondition.waitH  s     %'''U#		%**, D)lln$$ *) 	(  	<<>$$U+		 % *)D)lln$$ *))s   D,B"A	D,B& .B$/B& 4D, C!CC!
D,$B& &6CC- C!!C*&D,-D):DD
D	D)D&"D))D,c                h   K    |       x}s"| j                          d{     |       x}s"|S 7 w)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)rE   )r?   	predicateresults      r    wait_forzCondition.wait_forZ  s?      '[(6())+ '[(6(  s   2022c                p    t        t        | j                        | j                  j	                               S )zm
        Return statistics about the current state of this condition.

        .. versionadded:: 3.0
        )r.   lenr   r   rH   r>   s    r    rH   zCondition.statisticsj  s'     #3t}}#5tzz7L7L7NOOr   r5   )r   r   rK   r   rM   )r   )r   r   rJ   rL   )r   zCallable[[], T]rJ   r   )rJ   r.   )r   r   r   r   r   r   rl   rv   r   rk   r~   rq   r*   r   r   rE   r   rH   r   r   r    r   r     su    #'K'., & %	
 
V.
.#	%$ Pr   r   c                      e Zd Zddd	 	 	 	 	 	 	 ddZddd	 	 	 	 	 ddZddZ	 	 	 	 	 	 	 	 ddZddZdd	Zdd
Z	e
dd       Ze
dd       ZddZy)	SemaphoreNF	max_valuerc   c               t    	 t               j                  |||      S # t        $ r t        ||      cY S w xY w)Nr   r   )r   create_semaphorer	   SemaphoreAdapterr9   initial_valuer   rc   s       r    r:   zSemaphore.__new__t  sJ    	H$&77 8   ) 	H#MYGG	Hs    77c                   t        |t              st        d      |dk  rt        d      |+t        |t              st        d      ||k  rt        d      || _        y )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   )r?   r   r   rc   s       r    r   zSemaphore.__init__  sl     -->??19:: i- FGG=( M  *r   c                B   K   | j                          d {    | S 7 wr5   rj   r>   s    r    rl   zSemaphore.__aenter__  s     lln 	s   c                ,   K   | j                          y wr5   rp   rr   s       r    rv   zSemaphore.__aexit__  rw   rx   c                   K   t         w)z5Decrement the semaphore value, blocking if necessary.r<   r>   s    r    rk   zSemaphore.acquire  r{   rF   c                    t         )r   r<   r>   s    r    r~   zSemaphore.acquire_nowait  r   r   c                    t         )zIncrement the semaphore value.r<   r>   s    r    rq   zSemaphore.release  rA   r   c                    t         )z#The current value of the semaphore.r<   r>   s    r    valuezSemaphore.value  
     "!r   c                    t         )z#The maximum value of the semaphore.r<   r>   s    r    r   zSemaphore.max_value  r   r   c                    t         )zm
        Return statistics about the current state of this semaphore.

        .. versionadded:: 3.0
        r<   r>   s    r    rH   zSemaphore.statistics  r   r   )r   r   r   
int | Nonerc   r)   rJ   r   )r   r   r   r   rc   r)   rJ   r   r   rK   rJ   r   rJ   r   rJ   r1   )r   r   r   r:   r   rl   rv   rk   r~   rq   r_   r   r   rH   r   r   r    r   r   s  s    
 !%"HH 	H
 H 
H$ !%"** 	*
 **, & %	
 
""" " " " ""r   r   c                       e Zd ZU dZded<   ddd	 	 	 	 	 	 	 ddZddd	 	 	 	 	 	 	 d fdZedd       Zdd	Z	dd
Z
ddZedd       Zedd       ZddZ xZS )r   NzSemaphore | None_internal_semaphoreFr   c               ,    t         j                  |       S r5   rS   r   s       r    r:   zSemaphoreAdapter.__new__  s     ~~c""r   c               F    t         |   |||       || _        || _        y )Nr   )superr   _initial_value
_max_value)r?   r   r   rc   	__class__s       r    r   zSemaphoreAdapter.__init__  s(     	),W+#r   c                    | j                   4t               j                  | j                  | j                        | _         | j                   S )Nr   )r   r   r   r   r   r>   s    r    
_semaphorezSemaphoreAdapter._semaphore  sG    ##+'8':'K'K##t (L (D$ '''r   c                T   K   | j                   j                          d {    y 7 wr5   )r   rk   r>   s    r    rk   zSemaphoreAdapter.acquire  s     oo%%'''r\   c                8    | j                   j                          y r5   )r   r~   r>   s    r    r~   zSemaphoreAdapter.acquire_nowait  s    &&(r   c                8    | j                   j                          y r5   )r   rq   r>   s    r    rq   zSemaphoreAdapter.release  s    !r   c                ^    | j                   | j                  S | j                  j                  S r5   )r   r   r   r   r>   s    r    r   zSemaphoreAdapter.value  s*    ##+&&&$$$r   c                    | j                   S r5   )r   r>   s    r    r   zSemaphoreAdapter.max_value  s    r   c                f    | j                   t        d      S | j                  j                         S r^   )r   r1   r   rH   r>   s    r    rH   zSemaphoreAdapter.statistics  s,    ##+&Q77))++r   )r   r   r   r   rc   r)   rJ   r   )r   r   r   r   rc   r)   rJ   rL   r   rK   r   r   r   )r   r   r   r   r   r:   r   r_   r   rk   r~   rq   r   r   rH   __classcell__)r   s   @r    r   r     s    ,0)0 !%"## 	#
 # 
# !%"	$	$ 		$
 	$ 
	$ ( (()" % %  ,r   r   c                      e Zd ZddZddZ	 	 	 	 	 	 	 	 ddZedd       Zej                  dd       Zedd       Z	edd       Z
ddZdd	Zdd
ZddZddZddZddZy)CapacityLimiterc                j    	 t               j                  |      S # t        $ r t        |      cY S w xY wr5   )r   create_capacity_limiterr	   CapacityLimiterAdapterr9   r%   s     r    r:   zCapacityLimiter.__new__  s5    	8$&>>|LL( 	8),77	8s    22c                   K   t         wr5   r<   r>   s    r    rl   zCapacityLimiter.__aenter__	  s     !!rF   c                   K   t         wr5   r<   rr   s       r    rv   zCapacityLimiter.__aexit__        "!rF   c                    t         )aM  
        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.

        r<   r>   s    r    r%   zCapacityLimiter.total_tokens  s
     "!r   c                    t         r5   r<   r?   r   s     r    r%   zCapacityLimiter.total_tokens#  rA   r   c                    t         )z7The number of tokens that have currently been borrowed.r<   r>   s    r    r#   zCapacityLimiter.borrowed_tokens'  r   r   c                    t         )z7The number of tokens currently available to be borrowedr<   r>   s    r    available_tokensz CapacityLimiter.available_tokens,  r   r   c                    t         )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>   s    r    r~   zCapacityLimiter.acquire_nowait1  
     "!r   c                    t         )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?   borrowers     r    acquire_on_behalf_of_nowaitz+CapacityLimiter.acquire_on_behalf_of_nowait;  r  r   c                   K   t         w)zr
        Acquire a token for the current task, waiting if necessary for one to become
        available.

        r<   r>   s    r    rk   zCapacityLimiter.acquireE  r   rF   c                   K   t         w)z
        Acquire a token, waiting if necessary for one to become available.

        :param borrower: the entity borrowing a token

        r<   r  s     r    acquire_on_behalf_ofz$CapacityLimiter.acquire_on_behalf_ofM  s      "!rF   c                    t         )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>   s    r    rq   zCapacityLimiter.releaseV  r  r   c                    t         )z
        Release the token held by the given borrower.

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

        r<   r  s     r    release_on_behalf_ofz$CapacityLimiter.release_on_behalf_of`  r  r   c                    t         )zl
        Return statistics about the current state of this limiter.

        .. versionadded:: 3.0

        r<   r>   s    r    rH   zCapacityLimiter.statisticsj  r   r   N)r%   r$   rJ   r   rK   r   rJ   r$   r   r$   rJ   rL   r   r  rT   rJ   rL   rJ   r"   )r   r   r   r:   rl   rv   r_   r%   setterr#   r   r~   r  rk   r	  rq   r  rH   r   r   r    r   r     s    8""," &" %	"
 
" " " " " " " " """"""""r   r   c                      e Zd ZU dZded<   ddZddZedd       ZddZ		 	 	 	 	 	 	 	 ddZ
edd	       Zej                  dd
       Zedd       Zedd       ZddZddZddZddZddZddZddZy)r   NzCapacityLimiter | None_internal_limiterc                ,    t         j                  |       S r5   rS   r   s     r    r:   zCapacityLimiterAdapter.__new__w  rU   r   c                    || _         y r5   )r%   )r?   r%   s     r    r   zCapacityLimiterAdapter.__init__z  s
    (r   c                    | j                   (t               j                  | j                        | _         | j                   S r5   )r  r   r   _total_tokensr>   s    r    _limiterzCapacityLimiterAdapter._limiter}  s;    !!)%6%8%P%P""&D" %%%r   c                T   K   | j                   j                          d {    y 7 wr5   )r  rl   r>   s    r    rl   z!CapacityLimiterAdapter.__aenter__  s     mm&&(((r\   c                X   K   | j                   j                  |||       d {   S 7 wr5   )r  rv   rr   s       r    rv   z CapacityLimiterAdapter.__aexit__  s'      ]],,XwGGGGs   !*(*c                ^    | j                   | j                  S | j                   j                  S r5   )r  r  r%   r>   s    r    r%   z#CapacityLimiterAdapter.total_tokens  s,    !!)%%%%%222r   c                    t        |t              s|t        j                  urt	        d      |dk  rt        d      | j                  || _        y || j                  _	        y )Nz'total_tokens must be an int or math.infr   ztotal_tokens must be >= 1)
r   r   mathinfr   r   r  r  r  r%   r   s     r    r%   z#CapacityLimiterAdapter.total_tokens  sY    %%%txx*?EFFQY899!!)!&D%*"r   c                H    | j                   y| j                   j                  S )Nr   )r  r#   r>   s    r    r#   z&CapacityLimiterAdapter.borrowed_tokens  s#    !!)%%555r   c                ^    | j                   | j                  S | j                   j                  S r5   )r  r  r   r>   s    r    r   z'CapacityLimiterAdapter.available_tokens  s,    !!)%%%%%666r   c                8    | j                   j                          y r5   )r  r~   r>   s    r    r~   z%CapacityLimiterAdapter.acquire_nowait  s    $$&r   c                :    | j                   j                  |       y r5   )r  r  r  s     r    r  z2CapacityLimiterAdapter.acquire_on_behalf_of_nowait  s    11(;r   c                T   K   | j                   j                          d {    y 7 wr5   )r  rk   r>   s    r    rk   zCapacityLimiterAdapter.acquire  s     mm##%%%r\   c                V   K   | j                   j                  |       d {    y 7 wr5   )r  r	  r  s     r    r	  z+CapacityLimiterAdapter.acquire_on_behalf_of  s     mm00:::s   )')c                8    | j                   j                          y r5   )r  rq   r>   s    r    rq   zCapacityLimiterAdapter.release  s    r   c                :    | j                   j                  |       y r5   )r  r  r  s     r    r  z+CapacityLimiterAdapter.release_on_behalf_of  s    **84r   c                    | j                   t        d| j                  dd      S | j                   j                         S )Nr   r   )r#   r%   r&   r   )r  r"   r%   rH   r>   s    r    rH   z!CapacityLimiterAdapter.statistics  sD    !!), !!..	  %%0022r   )r%   r$   rJ   r   )r%   r$   rJ   rL   )rJ   r   rK   r   r  r  r   r  r  )r   r   r   r  r   r:   r   r_   r  rl   rv   r%   r  r#   r   r~   r  rk   r	  rq   r  rH   r   r   r    r   r   t  s    04-4#) & &)H,H &H %	H
 
H 3 3 
+ 
+ 6 6 7 7'<&; 5	3r   r   c                  >    e Zd ZdZdZdddZd	dZ	 	 	 	 	 	 	 	 d
dZy)ResourceGuarda  
    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                     || _         d| _        y NFr+  )r?   r,  s     r    r   zResourceGuard.__init__  s    !r   c                T    | j                   rt        | j                        d| _         y rY   )r-  r   r,  r>   s    r    	__enter__zResourceGuard.__enter__  s    ==#DKK00r   c                    d| _         y r/  )r-  rr   s       r    __exit__zResourceGuard.__exit__  s     r   N)using)r,  strrK   r   )r   r   r   r   	__slots__r   r1  r3  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(   r.   r1   r3   r7   ra   rg   r   r   r   r   r   r*  r   r   r    <module>rC     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   