Skip to main content
Join chatroom Documentation Status Latest PyPi version Latest conda-forge version Automated test status Test coverage

sniffio: Sniff out which async library your code is running under

You’re writing a library. You’ve decided to be ambitious, and support multiple async I/O packages, like Trio, and asyncio, and … You’ve written a bunch of clever code to handle all the differences. But… how do you know which piece of clever code to run?

This is a tiny package whose only purpose is to let you detect which async library your code is running under.

This library is maintained by the Trio project, as a service to the async Python community as a whole.

Quickstart

from sniffio import current_async_library
import trio
import asyncio

async def print_library():
    library = current_async_library()
    print("This is:", library)

# Prints "This is trio"
trio.run(print_library)

# Prints "This is asyncio"
asyncio.run(print_library())

For more details, including how to add support to new async libraries, please peruse our fine manual.

Metadata

Release files for sniffio 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sniffio 1.1.0
File Size Uploaded
sniffio-1.1.0.tar.gz 15.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sniffio 1.1.0
File Interpreter ABI Platform
sniffio-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / sniffio-1.1.0.tar.gz

Download URL sniffio-1.1.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8e3810100f69fe0edd463d02ad407112542a11ffdc29f67db2bf3771afb87a21
BLAKE2b-256 checksum
How to use checksums
ade563342a59850c6d285af0df92c86a778e1753235d6d392b9ae184217af852
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

Release files / sniffio-1.1.0-py3-none-any.whl

Download URL sniffio-1.1.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20ed6d5b46f8ae136d00b9dcb807615d83ed82ceea6b2058cecb696765246da5
BLAKE2b-256 checksum
How to use checksums
b3824bd4b7d9c0d1dc0fbfbc2a1e00138e7f3ab85bc239358fe9b78aa2ab586d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

Release history Release notifications | RSS feed

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page