我正在使用Python+Tornado制作一个web应用程序。编写了一个简单的处理程序,例如:
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)
但函数不是异步执行的。其他客户端正在等待,直到对第一个客户端执行查询。如何进行非阻塞执行?你知道吗
更新:
添加了decorator'@发电机'到您的async\u func\u test()函数,但仍被阻止((
添加装饰器@发电机'到您的async\u func\u test()函数
相关问题 更多 >
编程相关推荐