Ë
    òT•jÉ  ã                   óÈ   — d dl Z d dlmZ d dlmZmZmZ ddlmZ ddlm	Z	 ddlm
Z
 dZ G d	„ d
e j                  «      Ze G d„ d«      «       Zdee   defd„Zdee   defd„Zy)é    N)ÚTracebackType)ÚfinalÚOptionalÚTypeé   )Úevents)Ú
exceptions)Útasks)ÚTimeoutÚtimeoutÚ
timeout_atc                   ó    — e Zd ZdZdZdZdZdZy)Ú_StateÚcreatedÚactiveÚexpiringÚexpiredÚfinishedN)Ú__name__Ú
__module__Ú__qualname__ÚCREATEDÚENTEREDÚEXPIRINGÚEXPIREDÚEXITED© ó    ú'/usr/lib/python3.12/asyncio/timeouts.pyr   r      s   „ Ø€GØ€GØ€HØ€GØ�Fr   r   c            	       ó¬   — e Zd ZdZdee   ddfd„Zdee   fd„Zdee   ddfd„Zde	fd„Z
de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y)r   zšAsynchronous context manager for cancelling overdue coroutines.

    Use `timeout()` or `timeout_at()` rather than instantiating this class directly.
    ÚwhenÚreturnNc                 óX   — t         j                  | _        d| _        d| _        || _        y)zòSchedule a timeout that will trigger at a given loop time.

        - If `when` is `None`, the timeout will never trigger.
        - If `when < loop.time()`, the timeout will trigger on the next
          iteration of the event loop.
        N)r   r   Ú_stateÚ_timeout_handlerÚ_taskÚ_when)Úselfr!   s     r   Ú__init__zTimeout.__init__!   s%   € ô —n‘nˆŒà>BˆÔØ+/ˆŒ
Øˆ�
r   c                 ó   — | j                   S )zReturn the current deadline.)r'   ©r(   s    r   r!   zTimeout.when.   s   € à�z‰zÐr   c                 ó  — | j                   t        j                  urJ| j                   t        j                  u rt	        d«      ‚t	        d| j                   j
                  › d�«      ‚|| _        | j                  �| j                  j                  «        |€d| _        yt        j                  «       }||j                  «       k  r!|j                  | j                  «      | _        y|j                  || j                  «      | _        y)zReschedule the timeout.zTimeout has not been enteredzCannot change state of z TimeoutN)r$   r   r   r   ÚRuntimeErrorÚvaluer'   r%   Úcancelr   Úget_running_loopÚtimeÚ	call_soonÚ_on_timeoutÚcall_at)r(   r!   Úloops      r   Ú
reschedulezTimeout.reschedule2   sÒ   € à�;‰;œfŸn™nÑ,Ø�{‰{œfŸn™nÑ,Ü"Ð#AÓBÐBÜØ)¨$¯+©+×*;Ñ*;Ð)<¸HÐEóð ð ˆŒ
à× Ñ Ð,Ø×!Ñ!×(Ñ(Ô*àˆ<Ø$(ˆDÕ!ä×*Ñ*Ó,ˆDØ�t—y‘y“{Ò"Ø(,¯©°t×7GÑ7GÓ(H�Õ%à(,¯©°T¸4×;KÑ;KÓ(L�Õ%r   c                 óZ   — | j                   t        j                  t        j                  fv S )z$Is timeout expired during execution?)r$   r   r   r   r+   s    r   r   zTimeout.expiredI   s   € à�{‰{œvŸ™´·±Ð?Ð?Ð?r   c                 ó  — dg}| j                   t        j                  u r8| j                  �t	        | j                  d«      nd }|j                  d|› �«       dj                  |«      }d| j                   j                  › d|› d�S )NÚ é   zwhen=ú z
<Timeout [ú]ú>)r$   r   r   r'   ÚroundÚappendÚjoinr.   )r(   Úinfor!   Úinfo_strs       r   Ú__repr__zTimeout.__repr__M   ss   € ØˆtˆØ�;‰;œ&Ÿ.™.Ñ(Ø+/¯:©:Ð+A”5˜Ÿ™ QÔ'ÀtˆDØ�K‰K˜% ˜v˜Ô'Ø—8‘8˜D“>ˆØ˜DŸK™K×-Ñ-Ð.¨a°¨z¸Ð;Ð;r   c              ƒ   óJ  K  — | j                   t        j                  urt        d«      ‚t	        j
                  «       }|€t        d«      ‚t        j                  | _         || _        | j                  j                  «       | _	        | j                  | j                  «       | S ­w)Nz Timeout has already been enteredz$Timeout should be used inside a task)r$   r   r   r-   r
   Úcurrent_taskr   r&   Ú
cancellingÚ_cancellingr6   r'   )r(   Útasks     r   Ú
__aenter__zTimeout.__aenter__U   s}   è ø€ Ø�;‰;œfŸn™nÑ,ÜÐAÓBÐBÜ×!Ñ!Ó#ˆØˆ<ÜÐEÓFÐFÜ—n‘nˆŒØˆŒ
ØŸ:™:×0Ñ0Ó2ˆÔØ�‰˜Ÿ
™
Ô#Øˆùs   ‚B!B#Úexc_typeÚexc_valÚexc_tbc              ƒ   ó  K  — | j                   t        j                  t        j                  fv sJ ‚| j                  �!| j                  j                  «        d | _        | j                   t        j                  u rVt        j                  | _         | j                  j                  «       | j                  k  r|t        j                  u rt        |‚y | j                   t        j                  u rt        j                  | _         y ­w©N)r$   r   r   r   r%   r/   r   r&   ÚuncancelrG   r	   ÚCancelledErrorÚTimeoutErrorr   )r(   rJ   rK   rL   s       r   Ú	__aexit__zTimeout.__aexit__a   s¿   è ø€ ð �{‰{œvŸ~™~¬v¯©Ð?Ñ?Ð?Ð?à× Ñ Ð,Ø×!Ñ!×(Ñ(Ô*Ø$(ˆDÔ!à�;‰;œ&Ÿ/™/Ñ)Ü Ÿ.™.ˆDŒKà�z‰z×"Ñ"Ó$¨×(8Ñ(8Ò8¸XÌ×IbÑIbÑ=bô #¨Ð/ð ð �[‰[œFŸN™NÑ*Ü Ÿ-™-ˆDŒKàùs   ‚D Dc                 ó¬   — | j                   t        j                  u sJ ‚| j                  j	                  «        t        j
                  | _         d | _        y rN   )r$   r   r   r&   r/   r   r%   r+   s    r   r3   zTimeout._on_timeouty   s;   € Ø�{‰{œfŸn™nÑ,Ð,Ð,Ø�
‰
×ÑÔÜ—o‘oˆŒà $ˆÕr   )r"   r   )r"   N)r   r   r   Ú__doc__r   Úfloatr)   r!   r6   Úboolr   ÚstrrC   rI   r   ÚBaseExceptionr   rR   r3   r   r   r   r   r      s¯   „ ñð
˜X e™_ð °ó ð�h˜u‘oó ðM˜x¨™ð M°4ó Mð.@˜ó @ð<˜#ó <ó
ðà˜4 Ñ.Ñ/ðð ˜-Ñ(ðð ˜Ñ'ð	ð
 
�$‰óô0%r   r   Údelayr"   c                 ór   — t        j                  «       }t        | �|j                  «       | z   «      S d«      S )a	  Timeout async 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 asyncio.timeout(10):  # 10 seconds timeout
    ...     await long_running_task()


    delay - value in seconds or None to disable timeout logic

    long_running_task() is interrupted by raising asyncio.CancelledError,
    the top-most affected timeout() context manager converts CancelledError
    into TimeoutError.
    N)r   r0   r   r1   )rY   r5   s     r   r   r   �   s5   € ô  ×"Ñ"Ó$€DÜ¨%Ð*;�4—9‘9“; Ñ&ÓFÐFÀÓFÐFr   r!   c                 ó   — t        | «      S )ab  Schedule the timeout at absolute time.

    Like timeout() but argument gives absolute 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 asyncio.timeout_at(loop.time() + 10):
    ...     await long_running_task()


    when - a deadline when timeout occurs or None to disable timeout logic

    long_running_task() is interrupted by raising asyncio.CancelledError,
    the top-most affected timeout() context manager converts CancelledError
    into TimeoutError.
    )r   )r!   s    r   r   r   •   s   € ô& �4‹=Ðr   )ÚenumÚtypesr   Útypingr   r   r   r9   r   r	   r
   Ú__all__ÚEnumr   r   rU   r   r   r   r   r   ú<module>ra      s   ðÛ å ß (Ñ (å Ý Ý ð€ôˆT�Y‰Yô ð ÷c%ð c%ó ðc%ðLG�8˜E‘?ð G wó Gð(�X˜e‘_ð ¨ô r   