0
votes

I'm using tcelery to run a task asynchronously with Tornado. Env : OSX, Python3.4

This is server.py :

from tornado import gen
from tornado import ioloop
from tornado.web import asynchronous, RequestHandler, Application

import tasks

import tcelery
tcelery.setup_nonblocking_producer()


class GenAsyncHandler(RequestHandler):
    @asynchronous
    @gen.coroutine
    def get(self):
        response = yield gen.Task(tasks.sleep.apply_async, args=[3])
        self.write(str(response.result))
        self.finish()

application = Application([
    (r"/gen-async-sleep", GenAsyncHandler)
])


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

When I run the server file this is the error trace returned :

Traceback (most recent call last): File "tornado_async.py", line 7, in import tcelery File "/Users/mohit/anaconda/envs/py34/lib/python3.4/site-packages/tcelery/init.py", line 8, in from .producer import NonBlockingTaskProducer File "/Users/mohit/anaconda/envs/py34/lib/python3.4/site-packages/tcelery/producer.py", line 10, in from celery.app.amqp import TaskProducer ImportError: cannot import name 'TaskProducer'

How can I fix this? Thanks

1

1 Answers

0
votes

The version of your tornado-celery is too low to support celery-4.1. You can install tornado-celery by "python setup.py install".