Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sniffio

Package Overview
Dependencies
Maintainers
0
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sniffio

Sniff out which async library your code is running under

  • 1.3.1
  • PyPI
  • Socket score

Maintainers
0

.. image:: https://img.shields.io/badge/chat-join%20now-blue.svg :target: https://gitter.im/python-trio/general :alt: Join chatroom

.. image:: https://img.shields.io/badge/docs-read%20now-blue.svg :target: https://sniffio.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

.. image:: https://img.shields.io/pypi/v/sniffio.svg :target: https://pypi.org/project/sniffio :alt: Latest PyPi version

.. image:: https://img.shields.io/conda/vn/conda-forge/sniffio.svg :target: https://anaconda.org/conda-forge/sniffio :alt: Latest conda-forge version

.. image:: https://travis-ci.org/python-trio/sniffio.svg?branch=master :target: https://travis-ci.org/python-trio/sniffio :alt: Automated test status

.. image:: https://codecov.io/gh/python-trio/sniffio/branch/master/graph/badge.svg :target: https://codecov.io/gh/python-trio/sniffio :alt: 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 <https://trio.readthedocs.io>, and asyncio <https://docs.python.org/3/library/asyncio.html>, 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

.. code-block:: python3

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 <https://sniffio.readthedocs.io>__.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc