Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Async WSGI support for tornado and asyncio

Project Description

asyncwsgi is a simple package for tornado and asyncio(WIP) to enable the use of the WSGI interface asynchronously. Behind the scenes greenlet is used to pause and resume each request.


  1. Decorate functions that require async with asyncwsgi.coroutine
  2. Use asyncwsgi.wrap to wrap the WSGI container.
  3. Run the event loop using



def my_view(request):
    http_client = AsyncHTTPClient()
    response = yield http_client.fetch('')
    return render(request, 'my_view.html', {'code': response.code})

# Patch django to run on tornado's event loop
def run(host, port, app, **options):
    container = asyncwsgi.wrap(WSGIContainer(app))
    http_server = HTTPServer(container)
    http_server.listen(port, host)

if __name__ == "__main__":
    from import runserver = run


import asyncwsgi
import bottle
from tornado.httpclient import AsyncHTTPClient
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop

def index():
    http_client = AsyncHTTPClient()
    response = yield http_client.fetch('')
    return 'Status: %d' % response.code

container = asyncwsgi.wrap(WSGIContainer(bottle.default_app()))
http_server = HTTPServer(container)


pip install asyncwsgi


  • asyncio not fully supported


MIT licensed. See LICENSE for details.

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(5.3 kB) Copy SHA256 Hash SHA256
Source None Apr 26, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers