Debian Codegraph @

/

debian python-sniffio 1.3.1-2debian python-sniffio-doc debian python3-sniffio python sniffio 1.3.1 bashdebianinimakemakefilepythonshelltomlyaml 27 files · 128 symbols
View dependency graph

Depends on

README (full)
 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_.

dir .github/
dir ci/
dir debian/
dir docs/
dir newsfragments/
dir sniffio/
file .coveragerc
file .gitignore
file .mypy.ini
file .readthedocs.yml
file .style.yapf
file CHEATSHEET.rst
file CODE_OF_CONDUCT.md
file CONTRIBUTING.md
file LICENSE
file LICENSE.APACHE2
file LICENSE.MIT
file MANIFEST.in
file README.rst
file ci.sh
file pyproject.toml
file test-requirements.txt