asyncwsgi
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.
Usage
Decorate functions that require async with asyncwsgi.coroutine
Use asyncwsgi.wrap to wrap the WSGI container.
Run the event loop using asyncwsgi.run
Examples
Django
@asyncwsgi.coroutine
def my_view(request):
http_client = AsyncHTTPClient()
response = yield http_client.fetch('http://www.google.com/')
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)
asyncwsgi.run(IOLoop.current())
if __name__ == "__main__":
...
from django.core.management.commands import runserver
runserver.run = run
Bottle
import asyncwsgi
import bottle
from tornado.httpclient import AsyncHTTPClient
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
@bottle.get('/')
@asyncwsgi.coroutine
def index():
http_client = AsyncHTTPClient()
response = yield http_client.fetch('http://www.google.com/')
return 'Status: %d' % response.code
container = asyncwsgi.wrap(WSGIContainer(bottle.default_app()))
http_server = HTTPServer(container)
http_server.listen(8080)
asyncwsgi.run(IOLoop.current())
Installation
pip install asyncwsgi
Todo
asyncio not fully supported
License
MIT licensed. See LICENSE for details.
Metadata
Release files for asyncwsgi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| asyncwsgi-0.1.zip | 5.3 kB | Without provenance | Details |
Release files / asyncwsgi-0.1.zip
| Download URL | asyncwsgi-0.1.zip |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec3fd446e3c18afc4eb36f9fa51eb7c99b62abaa5ad2d9ee342f13836f6d5584
|
|
BLAKE2b-256 checksum How to use checksums |
7679b13eff66df4ed99b5561a9a976f2204c3d24d6e7c3bc216e476a334e1f8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for asyncwsgi 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.