o
    #6d                     @  s   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZmZ d dlZddlmZ dZed	Ze Zd
ddd2ddZd3ddZd4ddZd5dd Zd6d"d#Zd7d%d&Zd8d(d)Zed9d+d,Zd:d;d0d1ZdS )<    )annotationsN)contextmanager)import_module)Any	AwaitableCallable	GeneratorTypeVar   )DeprecatedAwaitableFloat)asyncioZtrioT_Retvalr   )backendbackend_optionsfunc"Callable[..., Awaitable[T_Retval]]argsobjectr   strr   dict[str, Any] | Nonereturnc             
   G  s   zt  }W n
 t jy   Y n	w td| dztd| td}W n ty8 } ztd| |d}~ww d}t j	ddu rIt j
|}z|pMi }|j| g|R i |W |rct j| S S |rmt j| w w )u  
    Run the given coroutine function in an asynchronous event loop.

    The current thread must not be already running an event loop.

    :param func: a coroutine function
    :param args: positional arguments to ``func``
    :param backend: name of the asynchronous event loop implementation – currently either
        ``asyncio`` or ``trio``
    :param backend_options: keyword arguments to call the backend ``run()`` implementation with
        (documented :ref:`here <backend options>`)
    :return: the return value of the coroutine function
    :raises RuntimeError: if an asynchronous event loop is already running in this thread
    :raises LookupError: if the named backend is not found

    zAlready running z in this threadz..._backends._)packagezNo such backend: N)sniffiocurrent_async_libraryZAsyncLibraryNotFoundErrorRuntimeErrorr   __name__ImportErrorLookupErrorZcurrent_async_library_cvargetsetrunreset)r   r   r   r   asynclib_nameZasynclibexctoken r%   mC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\anyio/_core/_eventloop.pyr       s.   r    delayfloatNonec                   s   t  | I dH S )zi
    Pause the current task for the specified duration.

    :param delay: the duration, in seconds

    N)get_asynclibsleep)r'   r%   r%   r&   r+   J   s   r+   c                     s   t tjI dH  dS )z
    Pause the current task until it's cancelled.

    This is a shortcut for ``sleep(math.inf)``.

    .. versionadded:: 3.1

    N)r+   mathinfr%   r%   r%   r&   sleep_foreverT   s   	r.   deadlinec                   s$   t  }tt| | dI dH  dS )z
    Pause the current task until the given time.

    :param deadline: the absolute time to wake up at (according to the internal monotonic clock of
        the event loop)

    .. versionadded:: 3.1

    r   N)current_timer+   max)r/   nowr%   r%   r&   sleep_until`   s   
r3   r   c                   C  s   t t  tS )zo
    Return the current value of the event loop's internal clock.

    :return: the clock value (seconds)

    )r   r*   r0   r%   r%   r%   r&   r0   n   s   r0   tuple[str, ...]c                   C  s   t S )z5Return a tuple of the names of all built-in backends.)BACKENDSr%   r%   r%   r&   get_all_backendsx   s   r6   type[BaseException]c                   C  s   t  jS )z@Return the current async library's cancellation exception class.)r*   CancelledErrorr%   r%   r%   r&   get_cancelled_exc_class}   s   r9   Generator[Any, None, None]c                 c  s.    t jd|   }|t_zd V  W t`d S t`w Nzanyio._backends._)sysmodulesthreadlocalsZcurrent_async_module)r   moduler%   r%   r&   claim_worker_thread   s   r@   r"   
str | Noner   c                 C  s@   | d u rt  } d|  }ztj| W S  ty   t| Y S w r;   )r   r   r<   r=   KeyErrorr   )r"   
modulenamer%   r%   r&   r*      s   r*   )
r   r   r   r   r   r   r   r   r   r   )r'   r(   r   r)   )r   r)   )r/   r(   r   r)   )r   r   )r   r4   )r   r7   )r   r   r   r:   )N)r"   rA   r   r   )
__future__r   r,   r<   	threading
contextlibr   	importlibr   typingr   r   r   r   r	   r   Z_compatr   r5   r   localr>   r    r+   r.   r3   r0   r6   r9   r@   r*   r%   r%   r%   r&   <module>   s0    
/







	