pydoc > sniffio

Help on package sniffio:

NAME
    sniffio - Top-level package for sniffio.

PACKAGE CONTENTS
    _impl
    _tests (package)
    _version

CLASSES
    builtins.RuntimeError(builtins.Exception)
        sniffio._impl.AsyncLibraryNotFoundError

    class AsyncLibraryNotFoundError(builtins.RuntimeError)
     |  Method resolution order:
     |      AsyncLibraryNotFoundError
     |      builtins.RuntimeError
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.RuntimeError:
     |
     |  __init__(self, /, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.RuntimeError:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  __str__(self, /)
     |      Return str(self).
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

FUNCTIONS
    current_async_library() -> str
        Detect which async library is currently running.

        The following libraries are currently supported:

        ================   ===========  ============================
        Library             Requires     Magic string
        ================   ===========  ============================
        **Trio**            Trio v0.6+   ``"trio"``
        **Curio**           -            ``"curio"``
        **asyncio**                      ``"asyncio"``
        **Trio-asyncio**    v0.8.2+     ``"trio"`` or ``"asyncio"``,
                                        depending on current mode
        ================   ===========  ============================

        Returns:
          A string like ``"trio"``.

        Raises:
          AsyncLibraryNotFoundError: if called from synchronous context,
            or if the current async library was not recognized.

        Examples:

            .. code-block:: python3

               from sniffio import current_async_library

               async def generic_sleep(seconds):
                   library = current_async_library()
                   if library == "trio":
                       import trio
                       await trio.sleep(seconds)
                   elif library == "asyncio":
                       import asyncio
                       await asyncio.sleep(seconds)
                   # ... and so on ...
                   else:
                       raise RuntimeError(f"Unsupported library {library!r}")

DATA
    __all__ = ['current_async_library', 'AsyncLibraryNotFoundError', 'curr...
    current_async_library_cvar = <ContextVar name='current_async_library_c...
    thread_local = <sniffio._impl._ThreadLocal object>

VERSION
    1.3.1

FILE
    /home/chedong/.local/lib/python3.10/site-packages/sniffio/__init__.py


sniffio
NAME PACKAGE CONTENTS CLASSES
class AsyncLibraryNotFoundError(builtins.RuntimeError)
FUNCTIONS
current_async_library() -> str
DATA VERSION FILE

Generated by phpman v4.9.27-5-g2cb901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-20 02:05 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^