a
    (ñ»jN  ã                   @  s6  d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl	Z	erPd dl
mZ ddœdd	d
dœdd„Zddœdd	d
dœdd„Zddœdd„Zdddœdd„Zdddœdd„ZG dd„ deƒZeddœdd	ddœdd „ƒZeddœdd	ddœd!d"„ƒZd#ejv �r2d dlZeefD ]Zej e¡je	jd$�e_�qdS )%é    )ÚannotationsN)Úcontextmanager)ÚTYPE_CHECKINGÚNoReturn)Ú	GeneratorF©ÚshieldÚfloatÚboolztrio.CancelScope)Údeadliner   Úreturnc                C  s   t j| |d�S )a>  Use as a context manager to create a cancel scope with the given
    absolute deadline.

    Args:
      deadline (float): The deadline.
      shield (bool): Initial value for the `~trio.CancelScope.shield` attribute
          of the newly created cancel scope.

    Raises:
      ValueError: if deadline is NaN.

    ©r   r   )ÚtrioÚCancelScoper   © r   ú4E:\soccer\ml_env\Lib\site-packages\trio/_timeouts.pyÚ
move_on_at   s    r   )Úsecondsr   r   c                C  s0   | dk rt dƒ‚t | ¡r"t dƒ‚tj|| d�S )aœ  Use as a context manager to create a cancel scope whose deadline is
    set to now + *seconds*.

    The deadline of the cancel scope is calculated upon entering.

    Args:
      seconds (float): The timeout.
      shield (bool): Initial value for the `~trio.CancelScope.shield` attribute
          of the newly created cancel scope.

    Raises:
      ValueError: if ``seconds`` is less than zero or NaN.

    r   ú`seconds` must be non-negativez`seconds` must not be NaN)r   Zrelative_deadline)Ú
ValueErrorÚmathÚisnanr   r   )r   r   r   r   r   Úmove_on_after   s    
þr   r   )r   c                   Ã  s"   t j dd„ ¡I dH  tdƒ‚dS )z÷Pause execution of the current task forever (or until cancelled).

    Equivalent to calling ``await sleep(math.inf)``, except that if manually
    rescheduled this will raise a `RuntimeError`.

    Raises:
      RuntimeError: if rescheduled

    c                 S  s
   t jjjS )N)r   ÚlowlevelZAbortZ	SUCCEEDED)Ú_r   r   r   Ú<lambda>G   ó    zsleep_forever.<locals>.<lambda>Nz#Should never have been rescheduled!)r   r   Zwait_task_rescheduledÚRuntimeErrorr   r   r   r   Úsleep_forever=   s    
r   ÚNone)r   r   c                 Ã  s8   t | ƒ� tƒ I dH  W d  ƒ n1 s*0    Y  dS )a  Pause execution of the current task until the given time.

    The difference between :func:`sleep` and :func:`sleep_until` is that the
    former takes a relative time and the latter takes an absolute time
    according to Trio's internal clock (as returned by :func:`current_time`).

    Args:
        deadline (float): The time at which we should wake up again. May be in
            the past, in which case this function executes a checkpoint but
            does not block.

    Raises:
      ValueError: if deadline is NaN.

    N)r   r   )r   r   r   r   Úsleep_untilK   s    
r    )r   r   c                 Ã  sD   | dk rt dƒ‚| dkr*tj ¡ I dH  ntt ¡ |  ƒI dH  dS )a  Pause execution of the current task for the given number of seconds.

    Args:
        seconds (float): The number of seconds to sleep. May be zero to
            insert a checkpoint without actually blocking.

    Raises:
        ValueError: if *seconds* is negative or NaN.

    r   r   N)r   r   r   Ú
checkpointr    Úcurrent_time)r   r   r   r   Úsleep_   s
    r#   c                   @  s   e Zd ZdZdS )ÚTooSlowErrorzRRaised by :func:`fail_after` and :func:`fail_at` if the timeout
    expires.

    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r$   r   s   r$   z'Generator[trio.CancelScope, None, None]c                c  s@   t | |d��}|V  W d  ƒ n1 s(0    Y  |jr<t‚dS )aˆ  Creates a cancel scope with the given deadline, and raises an error if it
    is actually cancelled.

    This function and :func:`move_on_at` are similar in that both create a
    cancel scope with a given absolute deadline, and if the deadline expires
    then both will cause :exc:`Cancelled` to be raised within the scope. The
    difference is that when the :exc:`Cancelled` exception reaches
    :func:`move_on_at`, it's caught and discarded. When it reaches
    :func:`fail_at`, then it's caught and :exc:`TooSlowError` is raised in its
    place.

    Args:
      deadline (float): The deadline.
      shield (bool): Initial value for the `~trio.CancelScope.shield` attribute
          of the newly created cancel scope.

    Raises:
      TooSlowError: if a :exc:`Cancelled` exception is raised in this scope
        and caught by the context manager.
      ValueError: if deadline is NaN.

    r   N)r   Úcancelled_caughtr$   )r   r   Úscoper   r   r   Úfail_aty   s    $r+   c                c  s@   t | |d��}|V  W d  ƒ n1 s(0    Y  |jr<t‚dS )aÕ  Creates a cancel scope with the given timeout, and raises an error if
    it is actually cancelled.

    This function and :func:`move_on_after` are similar in that both create a
    cancel scope with a given timeout, and if the timeout expires then both
    will cause :exc:`Cancelled` to be raised within the scope. The difference
    is that when the :exc:`Cancelled` exception reaches :func:`move_on_after`,
    it's caught and discarded. When it reaches :func:`fail_after`, then it's
    caught and :exc:`TooSlowError` is raised in its place.

    The deadline of the cancel scope is calculated upon entering.

    Args:
      seconds (float): The timeout.
      shield (bool): Initial value for the `~trio.CancelScope.shield` attribute
          of the newly created cancel scope.

    Raises:
      TooSlowError: if a :exc:`Cancelled` exception is raised in this scope
        and caught by the context manager.
      ValueError: if *seconds* is less than zero or NaN.

    r   N)r   r)   r$   )r   r   r*   r   r   r   Ú
fail_after›   s    $r,   zsphinx.ext.autodoc)Úreturn_annotation)Ú
__future__r   r   ÚsysÚ
contextlibr   Útypingr   r   r   Úcollections.abcr   r   r   r   r    r#   Ú	Exceptionr$   r+   r,   ÚmodulesÚinspectÚcÚ	SignatureÚfrom_callableÚreplacer   Ú__signature__r   r   r   r   Ú<module>   s0   ýý!ý%