2
我正在使用Python + Tornado製作一個Web應用程序。寫一個簡單的處理程序,例如:簡單函數和龍捲風gen.engine
class AdminHandler(BaseHandler):
@tornado.web.authenticated
@tornado.web.asynchronous
@gen.engine
def get(self):
response = yield gen.Task(self.acync_func_test, 'my')
print response
self.render('admin/index.html')
def acync_func_test(self, argument, callback):
for i in xrange(1,59999000):
i**2+2-12
callback(argument)
但是函數不是異步執行的。其他客戶端正在等待,直到執行第一個查詢。如何使非阻塞執行?
更新:
加裝飾 '@ gen.engine' 你async_func_test()函數,但仍受阻((