Skip to content

tornado-celery is a non-blocking Celery client for Tornado web framework

Notifications You must be signed in to change notification settings

mayflaver/tornado-celery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tornado-celery

tornado-celery is a non-blocking Celery client for Tornado web framework

Hello, world

Here is a simple "Hello, world" example web app for Tornado::

import tornado.ioloop
import tornado.web
from tornado.gen import coroutine

from tasks import test
import torncelery


class MainHandler(tornado.web.RequestHandler):
    @coroutine
    def get(self):
        result = yield torncelery.async(test, "hello world")
        self.write("%s" % result )

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

Here is tasks.py::

from celery import Celery
import time 

celery = Celery('tasks', backend='redis://localhost', broker='amqp://')


@celery.task
def test(strs):
    return strs

run

start a worker:

celery -A tasks worker --loglevel=info -n new

and start tornado server.

About

tornado-celery is a non-blocking Celery client for Tornado web framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages