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.
pip install a2wsgiVerified import paths — ran on the pinned version, not inferred.
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.
Ensure the WSGI application minimizes blocking I/O or offload such operations to a separate thread pool if absolute necessary. The `a2wsgi` library does not magically make a synchronous app asynchronous.
Be mindful of request body sizes when running WSGI apps on ASGI servers. If handling very large bodies is critical, consider refactoring the application to be purely ASGI or use alternative streaming mechanisms where possible.
Always convert the 'inner' application to the interface required by the 'outer' middleware. For example, to run an ASGI middleware around a WSGI app, first convert the WSGI app to ASGI, then wrap it with the ASGI middleware: `ASGI_Middleware(YOUR_ASGI_MIDDLEWARE(a2wsgi.ASGIMiddleware(your_wsgi_app)))`.
Install the package using 'pip install a2wsgi'.
Ensure the import statement is correct: 'from a2wsgi import WSGIMiddleware'. If the error persists, update the package using 'pip install --upgrade a2wsgi'.
Ensure that 'WSGIMiddleware' is used to wrap a WSGI application correctly: 'asgi_app = WSGIMiddleware(wsgi_app)'.
Update the 'a2wsgi' package to the latest version using 'pip install --upgrade a2wsgi'.
Ensure that the WSGI application passed to 'WSGIMiddleware' is a callable object, typically a function or a class with a '__call__' method.
No dependency data recorded yet.