
    %h+                     P    S SK r S SKrS SKJr  S SKJr  S SKJrJr   " S S5      rg)    N)TracebackType)Any)OptionalTypec            	          \ rS rSrSrSS.S \\   S\\R                     SS4S jjr	SS jr
S	\\   S
\S\S\\   4S jrSS jrS	\\   S
\S\SS4S jr\S\4S j5       r\S\\   4S j5       rSS jrS	\\   SS4S jrSS jrSrg)timeout   aw  timeout context manager.

Useful in cases when you want to apply timeout logic around block
of code or in cases when asyncio.wait_for is not suitable. For example:

>>> with timeout(0.001):
...     async with aiohttp.get('https://github.com') as r:
...         await r.text()


timeout - value in seconds or None to disable timeout logic
loop - asyncio compatible event loop
N)loopr
   returnc                    Xl         Uc  [        R                  " 5       nO[        R                  " S[
        5        X l        S U l        SU l        S U l	        S U l
        g )Nz-The loop argument to timeout() is deprecated.F)_timeoutasyncioget_running_loopwarningswarnDeprecationWarning_loop_task
_cancelled_cancel_handler
_cancel_at)selfr   r
   s      A/var/www/html/env/lib/python3.13/site-packages/asgiref/timeout.py__init__timeout.__init__   sR      <++-DMMCEW 

#    c                 "    U R                  5       $ N	_do_enterr   s    r   	__enter__timeout.__enter__2   s    ~~r   exc_typeexc_valexc_tbc                 &    U R                  U5        g r   _do_exitr   r$   r%   r&   s       r   __exit__timeout.__exit__5   s     	hr   c                 *   #    U R                  5       $ 7fr   r   r!   s    r   
__aenter__timeout.__aenter__>   s     ~~s   c                 .   #    U R                  U5        g 7fr   r(   r*   s       r   	__aexit__timeout.__aexit__A   s      	hs   c                     U R                   $ r   )r   r!   s    r   expiredtimeout.expiredI   s    r   c                     U R                   b1  [        U R                   U R                  R                  5       -
  S5      $ g )Ng        )r   maxr   timer!   s    r   	remainingtimeout.remainingM   s0    ??&t)::C@@r   c                    U R                   c  U $ [        R                  " U R                  5      U l        U R                  c  [        S5      eU R                   S::  a'  U R                  R                  U R                  5        U $ U R                  R                  5       U R                   -   U l	        U R                  R                  U R                  U R                  5      U l        U $ )Nz4Timeout context manager should be used inside a taskr   )r   r   current_taskr   r   RuntimeError	call_soon_cancel_taskr8   r   call_atr   r!   s    r   r    timeout._do_enterT   s     == K))$**5
::I  ==AJJ  !2!23K**//+dmm;#zz11$//4CTCTUr   c                    U[         R                  L a/  U R                  (       a  S U l        S U l        [         R
                  eU R                  b.  U R                  b!  U R                  R                  5         S U l        S U l        g r   )r   CancelledErrorr   r   r   TimeoutErrorr   cancel)r   r$   s     r   r)   timeout._do_exith   sj    w---$//#'D DJ&&&==$)=)=)I  '')#'D 
r   c                 b    U R                   b"  U R                   R                  5         SU l        g g )NT)r   rE   r   r!   s    r   r?   timeout._cancel_tasks   s(    ::!JJ"DO "r   )r   r   r   r   r   r   )r   r   )r   N)__name__
__module____qualname____firstlineno____doc__r   floatr   AbstractEventLoopr   r"   r   BaseExceptionr   boolr+   r.   r1   propertyr4   r9   r    r)   r?   __static_attributes__ r   r   r   r      s   $ 59	% w001	
 
& }%  	
 
$  }%    	 
 
     8E?  (	m!4 	 	#r   r   )	r   r   typesr   typingr   r   r   r   rT   r   r   <module>rW      s"        !f# f#r   