HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/sniffio/__pycache__/_impl.cpython-310.pyc
o

���g�@snddlmZddlmZddlZddlZeddd�ZGdd�dej�Ze�Z	Gdd	�d	e
�Zd
efdd�Z
dS)
�)�
ContextVar)�OptionalN�current_async_library_cvar)�defaultc@seZdZdZdS)�_ThreadLocalN)�__name__�
__module__�__qualname__�name�rr�8/usr/local/lib/python3.10/dist-packages/sniffio/_impl.pyrsrc@seZdZdS)�AsyncLibraryNotFoundErrorN)rrr	rrrrr
sr
�returncCs�tj}|dur	|St��}|dur|SdtjvrCddl}z|j}Wn
ty.|j	j}Ynwz
|�dur8WdSWn	t
yBYnwdtjvrSddlm}|�rSdSt
d��)aeDetect which async library is currently running.

    The following libraries are currently supported:

    ================   ===========  ============================
    Library             Requires     Magic string
    ================   ===========  ============================
    **Trio**            Trio v0.6+   ``"trio"``
    **Curio**           -            ``"curio"``
    **asyncio**                      ``"asyncio"``
    **Trio-asyncio**    v0.8.2+     ``"trio"`` or ``"asyncio"``,
                                    depending on current mode
    ================   ===========  ============================

    Returns:
      A string like ``"trio"``.

    Raises:
      AsyncLibraryNotFoundError: if called from synchronous context,
        or if the current async library was not recognized.

    Examples:

        .. code-block:: python3

           from sniffio import current_async_library

           async def generic_sleep(seconds):
               library = current_async_library()
               if library == "trio":
                   import trio
                   await trio.sleep(seconds)
               elif library == "asyncio":
                   import asyncio
                   await asyncio.sleep(seconds)
               # ... and so on ...
               else:
                   raise RuntimeError(f"Unsupported library {library!r}")

    N�asyncior�curio)�
curio_runningz.unknown async library, or not in async context)�thread_localr
r�get�sys�modulesr�current_task�AttributeError�Task�RuntimeError�
curio.metarr
)�valuerrrrrr�current_async_librarys6)

�
��
�r)�contextvarsr�typingrr�	threadingr�localrrrr
�strrrrrr�<module>s�