asgiref
ASGI specs, helper code, and adapters
Decision gist · record as of 2026-08-14
Yes. asgiref is a mature, actively maintained library (Production/Stable status, recent release) with no known vulnerabilities, minimal dependencies, and permissive licensing. Install it if you're building or migrating to async Python web applications, especially with Django or Channels, or if you need to bridge sync and async code boundaries safely.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or higher.
- Low friction: pure Python wheel with a single runtime dependency (typing_extensions).
- Active maintenance with a recent release (31 days ago) and steady repository activity.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; you must include the license text and attribution in distributions.
last release 2026-07-14 (31 days) · last repo commit 2026-08-10 · 1,628 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 151,569,378 downloads/mo, #266 on PyPI
Alternatives
Verify before relying
pip install asgiref
from asgiref.sync import async_to_sync, sync_to_async
# Call async function from sync code
async def async_func():
return "result"
result = async_to_sync(async_func)()
# Call sync function from async code
def sync_func():
return "result"
result = await sync_to_async(sync_func)()- Whether the WSGI-to-ASGI adapter supports all extended WSGI features beyond what the description notes as unsupported.
- Performance characteristics and thread pool sizing behavior under high concurrency.
- Compatibility guarantees with specific async frameworks beyond Django/Channels.
What it is and what it does
asgiref is a foundational library that implements the ASGI (Asynchronous Server Gateway Interface) standard for Python, providing utilities to bridge the gap between synchronous and asynchronous code. It's primarily used in async web frameworks like Django Channels to allow synchronous code (such as traditional Django views) to run inside asynchronous servers.
The package's core strength is its function wrappers: AsyncToSync lets you call async functions from synchronous code by running them on an event loop, while SyncToAsync lets async code call synchronous functions by running them in a thread pool. It also includes a drop-in replacement for threading.local that works with asyncio tasks, server base classes for building stateless ASGI servers, and a WSGI-to-ASGI adapter to wrap legacy WSGI applications. The library handles the complex thread and event-loop management required to make these transitions safe and predictable.
Use it for
- Wrap Django views with SyncToAsync to run them inside an async ASGI server like Daphne.
- Call async database drivers or HTTP clients from synchronous legacy code without rewriting it.
- Adapt existing WSGI applications to run on ASGI servers for better concurrency.
- Build async-first applications that need to integrate synchronous third-party libraries.
- Manage thread-local and task-local state that spans both sync and async boundaries.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
asgiref is a mature, actively maintained library (Production/Stable status, recent release) with no known vulnerabilities, minimal dependencies, and permissive licensing. Install it if you're building or migrating to async Python web applications, especially with Django or Channels, or if you need to bridge sync and async code boundaries safely.
Install
asgiref on PyPI
Before you install
Low friction: pure Python wheel with a single runtime dependency (typing_extensions). Active maintenance with a recent release (31 days ago) and steady repository activity. Supports Python 3.10 and newer versions including 3.14 and free threading beta.
Requires Python 3.10 or higher.
License in practice
BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; you must include the license text and attribution in distributions.
Quickstart
pip install asgiref
from asgiref.sync import async_to_sync, sync_to_async
# Call async function from sync code
async def async_func():
return "result"
result = async_to_sync(async_func)()
# Call sync function from async code
def sync_func():
return "result"
result = await sync_to_async(sync_func)()
Verify before relying
- Whether the WSGI-to-ASGI adapter supports all extended WSGI features beyond what the description notes as unsupported.
- Performance characteristics and thread pool sizing behavior under high concurrency.
- Compatibility guarantees with specific async frameworks beyond Django/Channels.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetyping_extensions |
| Maintenance | Actively maintained 31 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 151,569,378 / month, #266 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Free Threading :: 2 - BetaTopic :: Internet :: WWW/HTTP |
Evidence: asgiref-3.12.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “async to sync decorator”
- asgirefProvides ASGI base libraries including sync-to-async and…
- unsyncDecorator-based library that runs async functions in an ambient event…
- onecacheOneCache provides LRU-based caching decorators for both synchronous…
Give your agent the search over MCP, or paste the wish link into any chat.
More WWW/HTTP packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
h11 is a pure-Python HTTP/1.1 protocol implementation that handles parsing and serializing HTTP messages without any built-in I/O, letting you integrate it with any network layer you choose.
HTTPX is a fully featured HTTP client library for Python that provides both sync and async APIs, with support for HTTP/1.1 and HTTP/2, plus an integrated command-line client.
Install it if you are building new projects or modernizing existing ones that rely on HTTP.
A minimal low-level HTTP client library that sends HTTP requests with thread-safe and task-safe connection pooling, supporting HTTP/1.1, HTTP/2, proxies, and both sync and async interfaces.
aiohttp is an async HTTP client and server framework built on asyncio, supporting both WebSockets and middleware-based routing for building concurrent web applications.
Install it if you need async HTTP client or server capabilities in asyncio-based applications.
See also a2wsgi · uvicorn · channels · unasync · synchronicity · asyncore-wsgi · channels-redis · crochet · syncer · daphne