Skip to main content

Sniff out which async library your code is running under

Project description

Join chatroom Documentation Status Latest PyPi 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 find 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

sniffio-1.0.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

sniffio-1.0.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file sniffio-1.0.0.tar.gz.

File metadata

  • Download URL: sniffio-1.0.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for sniffio-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2e9b81429e3b7c9e119fcee2673ee3be3229982adc68b3f59317863aba05ebb7
MD5 f1ee89409cd401ca1bed64bb5945e495
BLAKE2b-256 c8830e3953535271855718993595c582a0af7726b41beba683e63e1c3abc1982

See more details on using hashes here.

File details

Details for the file sniffio-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sniffio-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for sniffio-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afb4997584a920e6e378a81ded2b3e71a696b85a68c4bfbe4dadf1ba57a9ef45
MD5 3709de9d2ed5645668d99d1d4beebab9
BLAKE2b-256 ca0858f3b857b8bba832983e8c5dce5e3f8c677a5527e41cf61ff45effc78cae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page