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.
from django.contrib.auth.models import User
from slacker import adisp
from slacker import Slacker
from slacker.workers import DjangoWorker
AsyncUser = Slacker(User, DjangoWorker())
# 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]
(pep-342 syntax and adisp library are optional, callback-style code is also supported)
pip install tornado-slacker