简单的功能和龙卷风发电机发动机

2024-10-02 10:31:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用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()函数,但仍被阻止((


Tags: 函数testselfweb应用程序客户端responsedef

热门问题