pydoc > sniffio

📛 NAME

sniffio - Top-level package for sniffio.

🚀 Quick Reference

Use CaseCommandDescription
🔍 Detect current async librarycurrent_async_library()Returns a string like "trio", "asyncio", or "curio".
🛡️ Handle unknown/unsupported contexttry: ... except AsyncLibraryNotFoundErrorCatches error when called from synchronous code or unrecognised library.

📦 PACKAGE CONTENTS

🧬 CLASSES

🔴 class AsyncLibraryNotFoundError(builtins.RuntimeError)

Method resolution order:

AsyncLibraryNotFoundError
builtins.RuntimeError
builtins.Exception
builtins.BaseException
builtins.object

🔹 Data descriptors defined here

🔹 Methods inherited from builtins.RuntimeError

🔹 Static methods inherited from builtins.RuntimeError

🔹 Methods inherited from builtins.BaseException

🔹 Data descriptors inherited from builtins.BaseException

🔧 FUNCTIONS

🔧 current_async_library()

Detect which async library is currently running.

The following libraries are currently supported:

LibraryRequiresMagic string
🎵 TrioTrio v0.6+"trio"
🔮 Curio-"curio"
asyncio"asyncio"
🎵⚡ Trio-asynciov0.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:

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}")

📊 DATA

🏷️ VERSION

1.3.1

📁 FILE

/home/chedong/.local/lib/python3.10/site-packages/sniffio/__init__.py

sniffio
📛 NAME 🚀 Quick Reference 📦 PACKAGE CONTENTS 🧬 CLASSES
🔴 class AsyncLibraryNotFoundError(builtins.RuntimeError)
🔧 FUNCTIONS
🔧 current_async_library()
📊 DATA 🏷️ VERSION 📁 FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 16:06 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^