o
    US`cI                     @   sd   d dl mZ d dlZdd Zdd Zdd Zd	d
 Zdd ZG dd deZ	edd Z
dd ZdS )    )contextmanagerNc                 C   s   t j| dS )zUse as a context manager to create a cancel scope with the given
    absolute deadline.

    Args:
      deadline (float): The deadline.

    deadline)trioZCancelScoper    r   9/usr/local/lib/python3.10/dist-packages/trio/_timeouts.py
move_on_at   s   r   c                 C       | dk rt dtt |  S )zUse as a context manager to create a cancel scope whose deadline is
    set to now + *seconds*.

    Args:
      seconds (float): The timeout.

    Raises:
      ValueError: if timeout is less than zero.

    r   timeout must be non-negative)
ValueErrorr   r   current_timesecondsr   r   r   move_on_after   s   r   c                      s   t jdd I dH  dS )z}Pause execution of the current task forever (or until cancelled).

    Equivalent to calling ``await sleep(math.inf)``.

    c                 S   s
   t jjjS )N)r   lowlevelZAbortZ	SUCCEEDED)_r   r   r   <lambda>(   s   
 zsleep_forever.<locals>.<lambda>N)r   r   Zwait_task_rescheduledr   r   r   r   sleep_forever"   s   r   c                    s<   t |  t I dH  W d   dS 1 sw   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.

    N)r   r   r   r   r   r   sleep_until+   s   
"r   c                    sH   | dk r	t d| dkrtj I dH  dS 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.

    r   zduration must be non-negativeN)r   r   r   
checkpointr   r   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   O   s    r   c                 c   s>    t | }|V  W d   n1 sw   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.

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

    N)r   Zcancelled_caughtr   )r   scoper   r   r   fail_atV   s   
r   c                 C   r	   )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.

    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.

    r   r
   )r   r   r   r   r   r   r   r   
fail_aftero   s   r   )
contextlibr   r   r   r   r   r   r   	Exceptionr   r   r   r   r   r   r   <module>   s    	
