import os import time import tornado.webfrom tornado import gen from . import BaseHandlerclass RegisterHandler(BaseHandler): def get(self): self.render_html('register.html') @tornado.web.asynchronous @gen.coroutine def post(self): username = self.get_argument('username', None) email = self.get_argument('email', None) password = self.get_argument('password') data = {'username': username, 'email': email, 'password': password, 'timestamp': time.time()} if username and email: time.sleep(10) yield self.db.user.insert(data) self.redirect('/')class LoginHandler(BaseHandler): def get(self): self.render_html('login.html')我在注冊的時候用time.sleep(10)阻塞了10秒, 按理說我通過異步的方式在這段阻塞的時間內(nèi)是可以通過,瀏覽器訪問我的login頁面,但卻同樣被阻塞了。怎么解決這個問題還是我的代碼有問題?
tornado 異步阻塞問題
幕布斯7119047
2018-10-10 13:39:50