tornado-slacker is a Python library that provides an easy API for moving the work out of the tornado process / event loop.
Currently implemented methods are:
- execute the code in another server's http hook (django implementation is included);
- execute the code in a separate thread (thread pool is used);
- dummy immediate execution.
API example:
from django.contrib.auth.models import User
from slacker import adisp
from slacker import Slacker
from slacker.workers import DjangoWorker
AsyncUser = Slacker(User, DjangoWorker())
@adisp.process
def process_data():
# all the django ORM is supported; the query will be executed
# on remote end, this will not block the IOLoop
users = yield AsyncUser.objects.filter(is_staff=True)[:5]
print users
(pep-342 syntax and adisp library are optional, callback-style code is also supported)
Installation:
pip install tornado-slacker
Product's homepage
Requirements:
· Python