只是想tornado的异步函数-我想从我的处理程序来调用,但它保持它“有一名意外关键字'回调'”。
class MyHandler(tornado.web.RequestHandler):
@asynchronous
@gen.engine
def get(self):
response = yield gen.Task(self.dosomething, 'argument')
self.write(response)
self.finish()
def dosomething(self, myargument):
pass
本文地址 :CodeGo.net/485701/
-------------------------------------------------------------------------------------------------------------------------
1.非阻塞函数需要回调,在那里它传递的结果。
class MyHandler(tornado.web.RequestHandler):
@asynchronous
@gen.engine
def get(self):
response = yield gen.Task(self.dosomething, 'argument')
self.write(response)
self.finish()
def dosomething(self, myargument, callback):
return callback(myargument)