【发布时间】:2013-11-11 19:02:21
【问题描述】:
class RedisHandler(BaseHandler):
@tornado.web.authenticated
@tornado.web.asynchronous
@tornado.gen.engine
def post(self):
self.client = tornadoredis.Client()
self.client.connect()
yield tornado.gen.Task(self.client.subscribe,'notification')
self.client.listen(self.on_message)
def on_message(self,msg):
if msg.kind == 'message':
self.finish(dict(complete=True,message=msg.body))
return
以上代码引发:
RuntimeError: finish() 调用了两次
这可能是由于使用了没有@asynchronous 装饰器的异步操作造成的。
【问题讨论】:
标签: python redis tornado long-polling