a2wsgi is a Python library that enables seamless conversion between WSGI (Web Server Gateway Interface) and ASGI (Asynchronous Server Gateway Interface) applications. It acts as a middleware, allowing you to run WSGI apps on ASGI servers or ASGI apps on WSGI servers. The current version is 1.10.10, and it maintains an active release schedule with frequent minor updates, primarily focusing on bug fixes and performance improvements.
Install & Compatibility
Where this runs
tested against v1.10.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.930 runs
installs and imports cleanly · install 0.0s · import 0.244s · 18.2MB
glibcpy 3.10–3.930 runs
installs and imports cleanly · install 1.5s · import 0.208s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from a2wsgi import ASGIMiddleware
from a2wsgi import WSGIMiddleware
This example demonstrates how to convert a standard synchronous WSGI application into an ASGI application using `ASGIMiddleware`. The resulting `asgi_app` can then be served by any ASGI-compatible web server like Uvicorn.
from a2wsgi import ASGIMiddleware
# A simple synchronous WSGI application
def wsgi_app(environ, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain; charset=utf-8')]
start_response(status, headers)
return [b"Hello from WSGI!\nRequest Path: " + environ.get('PATH_INFO', '/').encode()]
# Convert the WSGI app to an ASGI app
asgi_app = ASGIMiddleware(wsgi_app)
# To run this converted ASGI app using an ASGI server like Uvicorn:
# 1. Save this code as 'app.py'
# 2. Install uvicorn: pip install uvicorn
# 3. Run from your terminal: uvicorn app:asgi_app --reload
# Then open http://127.0.0.1:8000/ in your browser.
print("WSGI application 'wsgi_app' successfully wrapped as an ASGI application 'asgi_app'.")
print("To serve it, use an ASGI server like Uvicorn (e.g., 'uvicorn app:asgi_app').")
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.