龙卷风芹菜不能使用gen.Task或CallBack [英] Tornado celery can't use gen.Task or CallBack
问题描述
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 TypeError(repr(o) + " is not JSON serializable")
TypeError: <bound method AsyncHandler.on_result
of <__main__.AsyncHandler object at 0x10e7a19d0>> is not JSON serializable
经纪人和后端都使用redis,我只是从 https://github.com/mher/tornado-celery
The broker and backends all use redis, I just copied from https://github.com/mher/tornado-celery
当我使用amqp代理和redis后端时,它可以很好地工作,但在使用redis代理时却不能.这是因为龙卷风异步不支持Redis代理吗?
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?
推荐答案
文档说:
注意:当前,回调仅适用于AMQP和Redis后端.要使用Redis后端,必须安装tornado-redis.
NOTE: Currently callbacks only work with AMQP and Redis backends. To use the Redis backend, you must install tornado-redis.
因此,龙卷风芹菜不支持将redis作为代理...当我使用Rabbitmq作为代理+ redis作为后端时,它可以工作.
So tornado-celery does not support redis as a broker... it works when I use rabbitmq as a broker + redis as a backend.
这篇关于龙卷风芹菜不能使用gen.Task或CallBack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!