o
    #6d                     @  s   d dl mZ d dlZd dlmZ d dlmZ ddlmZm	Z	 ddl
mZmZmZ dd	lmZ G d
d de	e Ze ZG dd ded Zddd#ddZG dd dee Zd$d%ddZd$d&ddZd'ddZd(d!d"ZdS ))    )annotationsN)TracebackType)warn   )	TaskGroup
TaskStatus   )DeprecatedAsyncContextManagerDeprecatedAwaitableDeprecatedAwaitableFloat)get_asynclibc                   @  s   e Zd Zdd	ddZdS )
_IgnoredTaskStatusNvalueobjectreturnNonec                 C  s   d S N selfr   r   r   iC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\anyio/_core/_tasks.pystarted      z_IgnoredTaskStatus.startedr   )r   r   r   r   )__name__
__module____qualname__r   r   r   r   r   r      s    r   c                   @  s   e Zd ZdZejddd$d	d
Zd%ddZed&ddZ	e	j
d'ddZ	ed(ddZed(ddZej
d)ddZd*ddZd+d!d"Zd#S ),CancelScopez
    Wraps a unit of work that can be made separately cancellable.

    :param deadline: The time (clock value) when this scope is cancelled automatically
    :param shield: ``True`` to shield the cancel scope from external cancellation
    Fdeadlineshieldr   floatr   boolr   c                C  s   t  j||dS )N)r   r   )r   r   )clsr   r   r   r   r   __new__    s   zCancelScope.__new__r
   c                 C     t )zCancel this scope immediately.NotImplementedErrorr   r   r   r   cancel%      zCancelScope.cancelc                 C  r$   )z
        The time (clock value) when this scope is cancelled automatically.

        Will be ``float('inf')`` if no timeout has been set.

        r%   r'   r   r   r   r   )      zCancelScope.deadliner   r   c                 C  r$   r   r%   r   r   r   r   r   3   r)   c                 C  r$   )z+``True`` if :meth:`cancel` has been called.r%   r'   r   r   r   cancel_called7   s   zCancelScope.cancel_calledc                 C  r$   )z
        ``True`` if this scope is shielded from external cancellation.

        While a scope is shielded, it will not receive cancellations from outside.

        r%   r'   r   r   r   r   <   r*   zCancelScope.shieldc                 C  r$   r   r%   r   r   r   r   r   F   r)   c                 C  r$   r   r%   r'   r   r   r   	__enter__J   r   zCancelScope.__enter__exc_typetype[BaseException] | Noneexc_valBaseException | Noneexc_tbTracebackType | Nonebool | Nonec                 C  r$   r   r%   )r   r-   r/   r1   r   r   r   __exit__M   s   zCancelScope.__exit__N)r   r    r   r!   r   r   )r   r
   )r   r    )r   r    r   r   )r   r!   )r   r!   r   r   r   r   r-   r.   r/   r0   r1   r2   r   r3   )r   r   r   __doc__mathinfr#   r(   propertyr   setterr+   r   r,   r4   r   r   r   r   r      s"    
		
r   Fr   r   r!   r   c                 C  s   t dt t j| dS )z
    Open a cancel scope.

    :param shield: ``True`` to shield the cancel scope from external cancellation
    :return: a cancel scope

    .. deprecated:: 3.0
       Use :class:`~CancelScope` directly.

    z?open_cancel_scope() is deprecated -- use CancelScope() directlyr<   )r   DeprecationWarningr   r   r<   r   r   r   open_cancel_scopeV   s
   r>   c                   @  s*   e Zd ZdddZdddZdddZdS )FailAfterContextManagercancel_scoper   c                 C  s
   || _ d S r   )_cancel_scope)r   r@   r   r   r   __init__i      
z FailAfterContextManager.__init__r   c                 C  s
   | j  S r   )rA   r,   r'   r   r   r   r,   l   rC   z!FailAfterContextManager.__enter__r-   r.   r/   r0   r1   r2   r3   c                 C  s    | j |||}| j jrt|S r   )rA   r4   r+   TimeoutError)r   r-   r/   r1   retvalr   r   r   r4   o   s   z FailAfterContextManager.__exit__N)r@   r   r5   r6   )r   r   r   rB   r,   r4   r   r   r   r   r?   h   s    

r?   delayfloat | Nonec                 C  s4   | durt   |  ntj}t  j||d}t|S )a  
    Create a context manager which raises a :class:`TimeoutError` if does not finish in time.

    :param delay: maximum allowed time (in seconds) before raising the exception, or ``None`` to
        disable the timeout
    :param shield: ``True`` to shield the cancel scope from external cancellation
    :return: a context manager that yields a cancel scope
    :rtype: :class:`~typing.ContextManager`\[:class:`~anyio.CancelScope`\]

    Nr   )r   current_timer8   r9   r   r?   )rF   r   r   r@   r   r   r   
fail_after|   s   rI   c                 C  s,   | durt   |  ntj}t  j||dS )aD  
    Create a cancel scope with a deadline that expires after the given delay.

    :param delay: maximum allowed time (in seconds) before exiting the context block, or ``None``
        to disable the timeout
    :param shield: ``True`` to shield the cancel scope from external cancellation
    :return: a cancel scope

    Nr   )r   rH   r8   r9   r   )rF   r   r   r   r   r   move_on_after   s   rJ   r   c                   C  s   t t  tS )a;  
    Return the nearest deadline among all the cancel scopes effective for the current task.

    :return: a clock value from the event loop's internal clock (or ``float('inf')`` if
        there is no deadline in effect, or ``float('-inf')`` if the current scope has
        been cancelled)
    :rtype: float

    )r   r   current_effective_deadliner   r   r   r   rK      s   

rK   r   c                   C  s
   t   S )z:
    Create a task group.

    :return: a task group

    )r   r   r   r   r   r   create_task_group   s   
rL   )r   r!   r   r   )F)rF   rG   r   r!   r   r?   )rF   rG   r   r!   r   r   )r   r   )r   r   )
__future__r   r8   typesr   warningsr   Z
abc._tasksr   r   Z_compatr	   r
   r   Z
_eventloopr   r   r   ZTASK_STATUS_IGNOREDr   r>   r?   rI   rJ   rK   rL   r   r   r   r   <module>   s     >
