Tornado celery can't use gen.Task or CallBack

自作多情 提交于 2019-12-12 09:41:10

问题


class AsyncHandler(tornado.web.RequestHandler):

    @tornado.web.asynchronous
    def get(self):
        tasks.sleep.apply_async(args=[5], callback=self.on_result)

    def on_result(self, response):
        self.write(str(response.result))
        self.finish()

raise error :

    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <bound method AsyncHandler.on_result 
of <__main__.AsyncHandler object at 0x10e7a19d0>> is not JSON serializable

The broker and backends all use redis, I just copied from https://github.com/mher/tornado-celery

When I use amqp broker and redis backends it works well, but not when using the redis broker. Is this because tornado async does not support redis broker?


回答1:


The doc says:

NOTE: Currently callbacks only work with AMQP and Redis backends. To use the Redis backend, you must install tornado-redis.

So tornado-celery does not support redis as a broker... it works when I use rabbitmq as a broker + redis as a backend.



来源:https://stackoverflow.com/questions/28804029/tornado-celery-cant-use-gen-task-or-callback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!