An easy way to seamlessly use Greenlet with Tornado
Project description
Greenlet-Tornado
================
An easy way to seamlessly use Greenlet with Tornado.
----------------------------------------------------
This allows you to write code as if it were synchronous, and not worry about callbacks at all.
You also don't have to use any special patterns, such as writing everything as a generator.
Overall this allows you to structure your program in a much more sensible, straightforward way.
It's also immensely helpful when porting synchronous code to Tornado.
Derived from this blog article:
<http://blog.joshhaas.com/2011/06/marrying-boto-to-tornado-greenlets-bring-them-together/>
Install
-------
pip install greenlet_tornado
Example Usage:
--------------
import tornado.web
from greenlet_tornado import greenlet_asynchronous, greenlet_fetch
class ExampleHandler(tornado.web.RequestHandler):
@greenlet_asynchronous
def get(self):
# ...
self.helper()
# ...
self.write("Hello World!")
def helper(self):
# Fetch something. greenlet_fetch() will block until the request is complete,
# but the tornado IOLoop can do other things in the meantime.
http_response = greenlet_fetch("http://www.mopub.com")
# ... Do something with the response ...
Run tests
---------
pip install -r requirements_tests.txt
nosetests -s --cover-branches --cover-erase --with-coverage --cover-inclusive --cover-package=greenlet_tornado --tests=tests
================
An easy way to seamlessly use Greenlet with Tornado.
----------------------------------------------------
This allows you to write code as if it were synchronous, and not worry about callbacks at all.
You also don't have to use any special patterns, such as writing everything as a generator.
Overall this allows you to structure your program in a much more sensible, straightforward way.
It's also immensely helpful when porting synchronous code to Tornado.
Derived from this blog article:
<http://blog.joshhaas.com/2011/06/marrying-boto-to-tornado-greenlets-bring-them-together/>
Install
-------
pip install greenlet_tornado
Example Usage:
--------------
import tornado.web
from greenlet_tornado import greenlet_asynchronous, greenlet_fetch
class ExampleHandler(tornado.web.RequestHandler):
@greenlet_asynchronous
def get(self):
# ...
self.helper()
# ...
self.write("Hello World!")
def helper(self):
# Fetch something. greenlet_fetch() will block until the request is complete,
# but the tornado IOLoop can do other things in the meantime.
http_response = greenlet_fetch("http://www.mopub.com")
# ... Do something with the response ...
Run tests
---------
pip install -r requirements_tests.txt
nosetests -s --cover-branches --cover-erase --with-coverage --cover-inclusive --cover-package=greenlet_tornado --tests=tests
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file greenlet_tornado-1.1.3.tar.gz
.
File metadata
- Download URL: greenlet_tornado-1.1.3.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 285ff3f3b7871e469d8428442862d55c499f1d418ab26fb66addd059b13a8f71 |
|
MD5 | 9d8beca870b5f9ffe2ec91cbe7b9473c |
|
BLAKE2b-256 | c1a4ddf5aa2a80616ca4a968c25223737002989874d2b8e5ab7f50cc344262b4 |