K i ddlmZddlmZddlZddlZeddZGddejZeZ Gdd e Z d e fd Z y) ) ContextVar)OptionalNcurrent_async_library_cvar)defaultceZdZdZy) _ThreadLocalN)__name__ __module__ __qualname__nameS/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sniffio/_impl.pyrr s  Drrc eZdZy)AsyncLibraryNotFoundErrorN)r r r r rrrrsrrreturncrtj}||Stj}||Sdtj vrddl} |j} |y dtj vrddl m }|rytd#t$r|jj}YVwxYw#t$rY[wxYw)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}") Nasynciorcurio) curio_runningz.unknown async library, or not in async context) thread_localr rgetsysmodulesr current_taskAttributeErrorTask RuntimeError curio.metarr)valuerrrs rcurrent_async_libraryr!sR   E  & * * ,E  CKK 5"//L ~) * #++, ? #8  5"<<44L 5    s$ BB*B'&B'* B65B6) contextvarsrtypingrr threadingrlocalrrrrstrr!r rrr'sT" ' $ 9??~   FsFr