asgiref
ASGI specs, helper code, and adapters
Install
asgiref on PyPI
pip
pip install asgirefuv
uv add asgirefpoetry
poetry add asgirefPackage facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing_extensions |
| Maintenance | actively maintained — 30 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: asgiref-3.12.1-py3-none-any.whl
About asgiref
from the package's own PyPI description — quoted content, verbatim
asgiref
.. image:: https://github.com/django/asgiref/actions/workflows/tests.yml/badge.svg :target: https://github.com/django/asgiref/actions/workflows/tests.yml
.. image:: https://img.shields.io/pypi/v/asgiref.svg :target: https://pypi.python.org/pypi/asgiref
ASGI is a standard for Python asynchronous web apps and servers to communicate with each other, and positioned as an asynchronous successor to WSGI. You can read more at https://asgi.readthedocs.io/en/latest/
This package includes ASGI base libraries, such as:
- Sync-to-async and async-to-sync function wrappers,
asgiref.sync - Server base classes,
asgiref.server - A WSGI-to-ASGI adapter, in
asgiref.wsgi
Function wrappers
These allow you to wrap or decorate async or sync functions to call them from the other style (so you can call async functions from a synchronous thread, or vice-versa).
In particular:
-
AsyncToSync lets a synchronous subthread stop and wait while the async function is called on the main thread's event loop, and then control is returned to the thread when the async function is finished.
-
SyncToAsync lets async code call a synchronous function,...
Read as markdown · JSON record · Source repository · Homepage · Docs
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
asgiref provides ASGI base libraries for building asynchronous Python web applications, including sync-to-async and async-to-sync function wrappers, server base classes, and a WSGI-to-ASGI adapter for bridging synchronous and asynchronous code.
Low friction: pure Python wheel with only typing_extensions as a runtime dependency. Actively maintained with a release 30 days ago and 1628 GitHub stars. Supports Python 3.10–3.14 and includes beta support for free threading.
BSD-3-Clause is permissive and imposes minimal restrictions; you may use, modify, and distribute asgiref freely in commercial and proprietary projects provided you retain the license notice.
Usage
pip install asgiref
from asgiref.sync import sync_to_async, async_to_sync
# Wrap a sync function to call from async code
@sync_to_async
def sync_function():
return "result"
# Wrap an async function to call from sync code
@async_to_sync
async def async_function():
return "result"
Requires Python 3.10 or higher.
Verdict: asgiref is a production-stable, actively maintained library essential for bridging synchronous and asynchronous Python code in ASGI applications. Its low install friction, permissive BSD license, zero known vulnerabilities, and broad Python version support make it a reliable choice for async-first web frameworks and middleware.
Needs verification
- Whether the thread_sensitive=False optimization is safe for your specific database or thread-bound dependencies.
- Performance characteristics of sync_to_async and async_to_sync under high concurrency in your target deployment.
Similar packages
permissive · top 1,000 on PyPI
synchronicitypermissive · top 1,000 on PyPI
threadpoolctlpermissive · top 1,000 on PyPI
sse-starlettepermissive · top 1,000 on PyPI
opentelemetry-util-httppermissive · top 1,000 on PyPI
uvicornpermissive · top 100 on PyPI
Djangopermissive · top 1,000 on PyPI
opencensus-contextpermissive · top 1,000 on PyPI
cached-propertypermissive · top 1,000 on PyPI
multitaskingpermissive · top 1,000 on PyPI