1
私は竜巻に慣れています。ノンブロッキング関数の作成方法は?
Coroutinesの一部についてはエキサイティングです。
私はブロック機能を最初に非ブロックに変換しようとします。
@tornado.concurrent.return_future
def calculate(callback):
start_time = time.time()
res = urllib2.urlopen("https://www.google.com/")
print time.time()-start_time
callback(res)
class MainHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
start_time = time.time()
res = yield [calculate(), calculate()]
print time.time()-start_time
しかし、私は得た:
1.41436505318
1.38487792015
2.80179595947
それはI/Oバウンドだので、私は過ごした合計時間が長い1時間に近いべきであると思いますが(1.41436505318)を過ごしました。 しかし、それはブロックされているようです。
私は何がうまくいかないのでしょうか?ブロック機能を非ブロック機能に変換するにはどうすればよいですか?