
    h                         S SK Jr  S SKJr  S SKrS SKr\" SSS9r " S S\R                  5      r\" 5       r	 " S S	\
5      rS
\4S jrg)    )
ContextVar)OptionalNcurrent_async_library_cvar)defaultc                       \ rS rSrSrSrg)_ThreadLocal   N )__name__
__module____qualname____firstlineno__name__static_attributes__r
       ?/var/www/html/env/lib/python3.13/site-packages/sniffio/_impl.pyr   r      s	     Dr   r   c                       \ rS rSrSrg)AsyncLibraryNotFoundError   r
   N)r   r   r   r   r   r
   r   r   r   r      s    r   r   returnc                     [         R                  n U b  U $ [        R                  5       n U b  U $ S[        R
                  ;   a  SSKn UR                  n U" 5       b  g S[        R
                  ;   a  SSKJn  U" 5       (       a  g[        S5      e! [         a    UR                  R                  n N_f = f! [         a     Ndf = f)a  Detect 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.metar   r   )valuer   r   r   s       r   current_async_libraryr%      s    R E&**,E CKK	5"//L	~)  * #++,??
#8   	5"<<44L	5
  		s$   B B7  B43B47
CC)contextvarsr   typingr   r   	threadingr   localr   r   r"   r   strr%   r
   r   r   <module>r+      sT    "  
 ' $ 
9??  ~	 	Fs Fr   