本文介绍了龙卷风芹菜不能使用gen.Task或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 fromhttps://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?
推荐答案
文档说:
因此,龙卷风芹菜不支持将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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!