Sniff out which async library your code is running under
Project description
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.
Documentation: https://sniffio.readthedocs.io
Bug tracker and source code: https://github.com/python-trio/sniffio
License: MIT or Apache License 2.0, your choice
Contributor guide: https://trio.readthedocs.io/en/latest/contributing.html
Code of conduct: Contributors are requested to follow our code of conduct in all project spaces.
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sniffio-1.3.1.tar.gz
.
File metadata
- Download URL: sniffio-1.3.1.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc |
|
MD5 | 1673edc4dfeb739130a87bcd7b477864 |
|
BLAKE2b-256 | a287a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd |
File details
Details for the file sniffio-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: sniffio-1.3.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2 |
|
MD5 | 995b1c07546ce03df296f3161a60fc4b |
|
BLAKE2b-256 | e94475a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40 |