sniffio
A Python library that detects which asynchronous I/O library (e.g., Trio, asyncio) is currently running in your code. Current version: 1.3.1, released on February 25, 2024. Maintained by the Trio project, it has a stable release cadence with updates approximately every 1-2 years.
Warnings
- breaking Dropped support for Python 3.5 and 3.6 in version 1.3.0
- deprecated Explicit version specifications in USES=python for '3.x+' are deprecated
Install
-
pip install sniffio
Imports
- current_async_library
from sniffio import current_async_library
Quickstart
import sniffio
import trio
import asyncio
async def print_library():
library = sniffio.current_async_library()
print(f'This is {library}')
# Prints 'This is trio'
trio.run(print_library)
# Prints 'This is asyncio'
asyncio.run(print_library())