sniffio


Namesniffio JSON
Version 1.3.1 PyPI version JSON
download
home_page
SummarySniff out which async library your code is running under
upload_time2024-02-25 23:20:04
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT OR Apache-2.0
keywords async trio asyncio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            .. 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.

* 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
  <https://trio.readthedocs.io/en/latest/code-of-conduct.html>`_
  in all project spaces.

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>`__.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "sniffio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "async,trio,asyncio",
    "author": "",
    "author_email": "\"Nathaniel J. Smith\" <njs@pobox.com>",
    "download_url": "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz",
    "platform": null,
    "description": ".. image:: https://img.shields.io/badge/chat-join%20now-blue.svg\r\n   :target: https://gitter.im/python-trio/general\r\n   :alt: Join chatroom\r\n\r\n.. image:: https://img.shields.io/badge/docs-read%20now-blue.svg\r\n   :target: https://sniffio.readthedocs.io/en/latest/?badge=latest\r\n   :alt: Documentation Status\r\n\r\n.. image:: https://img.shields.io/pypi/v/sniffio.svg\r\n   :target: https://pypi.org/project/sniffio\r\n   :alt: Latest PyPi version\r\n   \r\n.. image:: https://img.shields.io/conda/vn/conda-forge/sniffio.svg\r\n   :target: https://anaconda.org/conda-forge/sniffio \r\n   :alt: Latest conda-forge version   \r\n\r\n.. image:: https://travis-ci.org/python-trio/sniffio.svg?branch=master\r\n   :target: https://travis-ci.org/python-trio/sniffio\r\n   :alt: Automated test status\r\n\r\n.. image:: https://codecov.io/gh/python-trio/sniffio/branch/master/graph/badge.svg\r\n   :target: https://codecov.io/gh/python-trio/sniffio\r\n   :alt: Test coverage\r\n\r\n=================================================================\r\nsniffio: Sniff out which async library your code is running under\r\n=================================================================\r\n\r\nYou're writing a library. You've decided to be ambitious, and support\r\nmultiple async I/O packages, like `Trio\r\n<https://trio.readthedocs.io>`__, and `asyncio\r\n<https://docs.python.org/3/library/asyncio.html>`__, and ... You've\r\nwritten a bunch of clever code to handle all the differences. But...\r\nhow do you know *which* piece of clever code to run?\r\n\r\nThis is a tiny package whose only purpose is to let you detect which\r\nasync library your code is running under.\r\n\r\n* Documentation: https://sniffio.readthedocs.io\r\n\r\n* Bug tracker and source code: https://github.com/python-trio/sniffio\r\n\r\n* License: MIT or Apache License 2.0, your choice\r\n\r\n* Contributor guide: https://trio.readthedocs.io/en/latest/contributing.html\r\n\r\n* Code of conduct: Contributors are requested to follow our `code of\r\n  conduct\r\n  <https://trio.readthedocs.io/en/latest/code-of-conduct.html>`_\r\n  in all project spaces.\r\n\r\nThis library is maintained by the Trio project, as a service to the\r\nasync Python community as a whole.\r\n\r\n\r\nQuickstart\r\n----------\r\n\r\n.. code-block:: python3\r\n\r\n   from sniffio import current_async_library\r\n   import trio\r\n   import asyncio\r\n\r\n   async def print_library():\r\n       library = current_async_library()\r\n       print(\"This is:\", library)\r\n\r\n   # Prints \"This is trio\"\r\n   trio.run(print_library)\r\n\r\n   # Prints \"This is asyncio\"\r\n   asyncio.run(print_library())\r\n\r\nFor more details, including how to add support to new async libraries,\r\n`please peruse our fine manual <https://sniffio.readthedocs.io>`__.\r\n",
    "bugtrack_url": null,
    "license": "MIT OR Apache-2.0",
    "summary": "Sniff out which async library your code is running under",
    "version": "1.3.1",
    "project_urls": {
        "Changelog": "https://sniffio.readthedocs.io/en/latest/history.html",
        "Documentation": "https://sniffio.readthedocs.io/",
        "Homepage": "https://github.com/python-trio/sniffio"
    },
    "split_keywords": [
        "async",
        "trio",
        "asyncio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e94475a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40",
                "md5": "995b1c07546ce03df296f3161a60fc4b",
                "sha256": "2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"
            },
            "downloads": -1,
            "filename": "sniffio-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "995b1c07546ce03df296f3161a60fc4b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 10235,
            "upload_time": "2024-02-25T23:20:01",
            "upload_time_iso_8601": "2024-02-25T23:20:01.196159Z",
            "url": "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a287a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd",
                "md5": "1673edc4dfeb739130a87bcd7b477864",
                "sha256": "f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"
            },
            "downloads": -1,
            "filename": "sniffio-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1673edc4dfeb739130a87bcd7b477864",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 20372,
            "upload_time": "2024-02-25T23:20:04",
            "upload_time_iso_8601": "2024-02-25T23:20:04.057878Z",
            "url": "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-25 23:20:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "python-trio",
    "github_project": "sniffio",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "sniffio"
}
        
Elapsed time: 9.20112s