sniffio
Sniff out which async library your code is running under
Decision gist · record as of 2026-08-14
Yes. Sniffio is a tiny, stable, zero-dependency utility that solves a real problem for anyone writing async libraries. It's actively maintained, permissively licensed, and widely used (top 100 PyPI by downloads). Install it if you're building multi-framework async support; skip it if you're only targeting one framework.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Must be called from within an active async context (inside an async function running under asyncio, Trio, or another supported library).
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained by the Trio project with recent commits and stable release status.
License · maintenance · safety
MIT OR Apache-2.0 (permissive) — Dual-licensed under MIT or Apache-2.0 (your choice), both permissive. No restrictions on commercial or proprietary use.
last release 2024-02-25 (901 days) · last repo commit 2026-03-06 · 153 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 487,249,508 downloads/mo, #82 on PyPI
Alternatives
Verify before relying
from sniffio import current_async_library
import asyncio
async def check():
lib = current_async_library()
print(lib)
asyncio.run(check())- Complete list of supported async libraries beyond asyncio and Trio
- Whether detection works with nested or concurrent async contexts
What it is and what it does
Sniffio is a lightweight utility library that answers a single question: which async I/O framework is currently running your code? When you're writing a library that needs to support both asyncio and Trio (or other async frameworks), you need a way to branch your code path at runtime. This package provides exactly that—a `current_async_library()` function that returns the name of the active async library.
The package has no runtime dependencies and is pure Python, making it trivial to add to any project. It's maintained by the Trio project as a service to the broader async Python community. The detection works by inspecting the current execution context to identify which async library is active, allowing multi-framework libraries to adapt their behavior without requiring users to pass configuration flags.
Use it for
- Write a library that works with both asyncio and Trio without duplicating code paths
- Conditionally apply framework-specific optimizations or workarounds at runtime
- Debug or log which async framework a user's code is running under
- Build async utilities that need to behave differently depending on the underlying framework
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Sniffio is a tiny, stable, zero-dependency utility that solves a real problem for anyone writing async libraries. It's actively maintained, permissively licensed, and widely used (top 100 PyPI by downloads). Install it if you're building multi-framework async support; skip it if you're only targeting one framework.
Install
sniffio on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained by the Trio project with recent commits and stable release status.
Must be called from within an active async context (inside an async function running under asyncio, Trio, or another supported library).
License in practice
Dual-licensed under MIT or Apache-2.0 (your choice), both permissive. No restrictions on commercial or proprietary use.
Quickstart
from sniffio import current_async_library
import asyncio
async def check():
lib = current_async_library()
print(lib)
asyncio.run(check())
Verify before relying
- Complete list of supported async libraries beyond asyncio and Trio
- Whether detection works with nested or concurrent async contexts
Package facts
| License | MIT OR Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 901 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 487,249,508 / month, #82 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: AsyncIOFramework :: TrioIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy |
Evidence: sniffio-1.3.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “detect async library runtime”
- sniffioDetects which async library (asyncio, Trio, etc.) your code is…
- googletransGoogletrans translates text and detects languages by calling Google…
- bluetooth-adaptersEnumerates and locates Bluetooth adapters on a system, providing…
Give your agent the search over MCP, or paste the wish link into any chat.
Similar packages
Trio is an async I/O library that lets you write concurrent Python programs using async/await syntax, handling multiple network connections, file operations, and tasks simultaneously with a focus on correctness and ease of use.
Install it if you need to write concurrent I/O code and prefer structured concurrency principles and a simpler API over asyncio.
A pytest plugin that enables testing of async code written with Trio, allowing you to write and run async test functions directly within pytest.
AnyIO provides a unified asynchronous API that runs on either asyncio or Trio, implementing structured concurrency patterns and offering high-level networking, synchronization, and I/O primitives.
Install it if you need to support multiple async backends, want structured concurrency in asyncio, or are building a library that should work across both ecosystems.
Implements WebSocket protocol (RFC 6455) for both client and server using the Trio async framework, built on wsproto for protocol handling and I/O.
However, be aware the project is on life-support maintenance with infrequent releases (535 days since last release).
A flake8 plugin that detects async-related issues in code using Trio, AnyIO, or asyncio, flagging bugs, dead code, performance problems, and idiom violations.
Allows you to call async functions from synchronous code that runs within an asyncio or Trio event loop, bridging the gap between sync and async codebases without threading.
See also pytest-aio · trio-typing · python-socks · asyncclick