0
文檔(http://www.tornadoweb.org/en/stable/web.html#tornado.web.stream_request_body)是writen是 There is a subtle interaction between data_received and asynchronous prepare: The first call to data_received may occur at any point after the call to prepare has returned or yielded.
但如果我嘗試Python的龍捲風流請求體
@tornado.web.stream_request_body
class HTTPHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def prepare(self):
yield long_time_operation()
@tornado.gen.coroutine
def data_received(self, chunk):
print("Data received")
DATA_RECEIVED不叫之前準備返回(不會產生)。爲什麼?
什麼是long_time_operation?它內部產量還是阻塞? –
這是異步操作,調用併產生長時間的AsyncHTTPClient.fetch方法 – COUNTERKILL