
    ,h#                        d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZ ej                  dk\  rd dlm
Z
 nd Z
ej                  dk\  rddZndd	Zd
ZdZdee   ddfdZdee   ddfdZ G d dej"                        Ze
 G d d             Zy)    N)TracebackType)OptionalType)      )finalc                 B    	 d| _         | S # t        t        f$ r Y | S w xY w)a  This decorator can be used to indicate to type checkers that
        the decorated method cannot be overridden, and decorated class
        cannot be subclassed. For example:

            class Base:
                @final
                def done(self) -> None:
                    ...
            class Sub(Base):
                def done(self) -> None:  # Error reported by type checker
                    ...
            @final
            class Leaf:
                ...
            class Other(Leaf):  # Error reported by type checker
                ...

        There is no runtime checking of these properties. The decorator
        sets the ``__final__`` attribute to ``True`` on the decorated object
        to allow runtime introspection.
        T)	__final__AttributeError	TypeError)fs    b/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/websockets/asyncio/async_timeout.pyr   r      s5    ,	AK  	* 	 	s    returnc                 $    | j                          y N)uncanceltasks    r   _uncancel_taskr   9   s        c                      y r    r   s    r   r   r   >   s    r   z4.0.3)timeout
timeout_atTimeoutdelayr   c                 r    t        j                         }| |j                         | z   }nd}t        ||      S )ar  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:

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


    delay - value in seconds or None to disable timeout logic
    N)asyncioget_running_looptimer   )r   loopdeadlines      r   r   r   H   s:     ##%D99;&8T""r   r"   c                 B    t        j                         }t        | |      S )a  Schedule the timeout at absolute time.

    deadline argument points on the time in the same clock system
    as loop.time().

    Please note: it is not POSIX time but a time with
    undefined starting base, e.g. the time of the system power on.

    >>> async with timeout_at(loop.time() + 10):
    ...     async with aiohttp.get('https://github.com') as r:
    ...         await r.text()


    )r   r   r   )r"   r!   s     r   r   r   ]   s     ##%D8T""r   c                       e Zd ZdZdZdZdZy)_StateINITENTERTIMEOUTEXITN)__name__
__module____qualname__r&   r'   r(   r)   r   r   r   r%   r%   p   s    DEGDr   r%   c            	       P   e Zd ZdZdee   dej                  ddfdZddZ	dee
e      d	ee   d
ee   dee   fdZddZdee
e      d	ee   d
ee   dee   fdZedefd       Zedee   fd       ZddZddZdeddfdZdeddfdZddZddZdee
e      ddfdZddZy)r   )	_deadline_loop_state_timeout_handler_taskr"   r!   r   Nc                     || _         t        j                  | _        d | _        d | _        |d | _        y | j                  |       y r   )r/   r%   r&   r0   r2   r1   r.   update)selfr"   r!   s      r   __init__zTimeout.__init__   s>     
kk7;
 $!DNKK!r   c                 ^    t        j                  dt        d       | j                          | S )Nz>with timeout() is deprecated, use async with timeout() instead   )
stacklevel)warningswarnDeprecationWarning	_do_enterr5   s    r   	__enter__zTimeout.__enter__   s(    L	

 	r   exc_typeexc_valexc_tbc                 &    | j                  |       y r   _do_exitr5   r@   rA   rB   s       r   __exit__zTimeout.__exit__   s     	hr   c                 .   K   | j                          | S wr   )r=   r>   s    r   
__aenter__zTimeout.__aenter__   s        c                 .   K   | j                  |       y wr   rD   rF   s       r   	__aexit__zTimeout.__aexit__   s      	hrJ   c                 <    | j                   t        j                  k(  S )z$Is timeout expired during execution?)r0   r%   r(   r>   s    r   expiredzTimeout.expired   s     {{fnn,,r   c                     | j                   S r   )r.   r>   s    r   r"   zTimeout.deadline   s    ~~r   c                     | j                   t        j                  t        j                  fvr"t	        d| j                   j
                         | j                          y)z Reject scheduled timeout if any.invalid state N)r0   r%   r&   r'   RuntimeErrorvalue_rejectr>   s    r   rejectzTimeout.reject   sC     ;;v{{FLL990A0A/BCDDr   c                 n    d | _         | j                  "| j                  j                          d | _        y y r   )r2   r1   cancelr>   s    r   rT   zTimeout._reject   s4    
  ,!!((*$(D! -r   r   c                 ^    | j                   }|t        d      | j                  ||z          y)zAdvance timeout on delay seconds.

        The delay can be negative.

        Raise RuntimeError if shift is called when deadline is not scheduled
        Nz1cannot shift timeout if deadline is not scheduled)r.   rR   r4   )r5   r   r"   s      r   shiftzTimeout.shift   s0     >>RSSHu$%r   c                 Z   | j                   t        j                  k(  rt        d      | j                   t        j                  k(  rt        d      | j
                  | j
                  j                          || _        | j                   t        j                  k7  r| j                          yy)aT  Set deadline to absolute value.

        deadline argument points on the time in the same clock system
        as loop.time().

        If new deadline is in the past the timeout is raised immediately.

        Please note: it is not POSIX time but a time with
        undefined starting base, e.g. the time of the system power on.
        z1cannot reschedule after exit from context managerz!cannot reschedule expired timeoutN)
r0   r%   r)   rR   r(   r1   rW   r.   r&   _reschedule)r5   r"   s     r   r4   zTimeout.update   s     ;;&++%RSS;;&..(BCC  ,!!((*!;;&++% &r   c                    | j                   t        j                  k(  sJ | j                  }|y | j                  j                         }| j                  | j                  j                          t        j                         | _
        ||k  r+| j                  j                  | j                        | _        y | j                  j                  || j                        | _        y r   )r0   r%   r'   r.   r/   r    r1   rW   r   current_taskr2   	call_soon_on_timeoutcall_at)r5   r"   nows      r   r[   zTimeout._reschedule   s    {{fll**>>jjoo  ,!!((*))+
s?$(JJ$8$89I9I$JD!$(JJ$6$6xAQAQ$RD!r   c                     | j                   t        j                  k7  r"t        d| j                   j                         t        j
                  | _         | j                          y )NrQ   )r0   r%   r&   rR   rS   r'   r[   r>   s    r   r=   zTimeout._do_enter   sF    ;;&++%0A0A/BCDDllr   c                 .   |t         j                  u r^| j                  t        j                  k(  rA| j
                  J t        | j
                         d | _        d | _        t         j                  t        j                  | _        | j                          y r   )r   CancelledErrorr0   r%   r(   r2   r   r1   TimeoutErrorr)   rT   )r5   r@   s     r   rE   zTimeout._do_exit  sj    w---$++2O::))4::&$(D!DJ&&&kkr   c                     | j                   J | j                   j                          t        j                  | _        d | _        y r   )r2   rW   r%   r(   r0   r1   r>   s    r   r_   zTimeout._on_timeout  s2    zz%%

nn $r   )r   r   )r   N)r*   r+   r,   	__slots__r   floatr   AbstractEventLoopr6   r?   r   BaseExceptionr   boolrG   rI   rL   propertyrN   r"   rU   rT   rY   r4   r[   r=   rE   r_   r   r   r   r   r   w   sX   & NI" "/6/H/H"	"4./ -( '	
 
$4./ -( '	
 
$ - - - (5/  )
&5 
&T 
&u  *S 
$}*=!> 
4 
%r   )r   zasyncio.Task[object]r   N)r   enumsysr:   typesr   typingr   r   version_infor   r   __version____all__rh   r   r   Enumr%   r   r   r   r   <module>ru      s      
   ! wD w
  /#8E? #y #*#% #Y #&TYY  _% _% _%r   