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!

Celery integration with Tornado

Project Description

Celery integration with Tornado.


You can install Totoro either via the Python Package Index (PyPI) or from source.

To install using pip, simply:

$ sudo pip install totoro

or alternatively (you really should be using pip though):

$ sudo easy_install totoro

or from source:

$ sudo python install

Totoro can only support AMQP(RabbitMQ) by default. To use the Redis, you can specify the requirements on the pip comand-line by using brackets.

$ sudo pip install totoro[redis]

Hello, world

Here is a simple “Hello, world!” example for calling celery tasks from Tornado RequestHandler:

#!/usr/bin/env python

import tornado.httpserver
import tornado.ioloop
import tornado.web

from tornado import gen
import totoro
from totoro.test.celery_tasks import tasks

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        response = yield gen.Task(tasks.echo.apply_async, args=['Hello world!'])

def main():
    application = tornado.web.Application([
        (r"/", MainHandler),
    http_server = tornado.httpserver.HTTPServer(application)

if __name__ == "__main__":

To run celery worker for the example:

$ python -m totoro.test.runtasks worker -l INFO

Configuration and defaults


New in version 0.1.2

The setting must a dict that used to configure the AMQP(RabbitMQ) connection pool. It supporting the following keys:

  • max_idle_connections - Max number of keeping connections. Defaults to 3.
  • max_open_connections - Max number of opened connections, 0 means no limit. Defaults to 10.
  • max_recycle_sec - How long connections are recycled. Defaults to 3600.

Example configuration:

celery = Celery("totoro_celery_tasks")
    CELERY_ACCEPT_CONTENT=['json'],  # Ignore other content
        'max_idle_connections': 1,
        'max_open_connections': 10,
        'max_recycle_sec': 3600


To run the tests for the AMQP(broker/backend):

$ python -m totoro.test.runtasks worker -l INFO
$ python -m totoro.test.runtests

To run the tests for the AMQP broker with the Redis backend:

$ CELERY_RESULT_BACKEND=redis://  python -m totoro.test.runtasks worker -l INFO
$ CELERY_RESULT_BACKEND=redis://  python -m totoro.test.runtests

To run the tests for the Redis(broker/backend):

$ BROKER_URL=redis://  CELERY_RESULT_BACKEND=redis:// python -m totoro.test.runtasks worker -l INFO
$ BROKER_URL=redis://  CELERY_RESULT_BACKEND=redis:// python -m totoro.test.runtests
Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
totoro-0.1.3-py27-none-any.whl (16.2 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Feb 18, 2016 (24.1 kB) Copy SHA256 Checksum SHA256 Source Feb 18, 2016

Supported By

WebFaction WebFaction Technical Writing 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 Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting