Python龙卷风流请求正文

时间:2017-01-23 21:57:02

标签: python tornado

文档(http://www.tornadoweb.org/en/stable/web.html#tornado.web.stream_request_body)正在写入 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. 但是,如果我尝试

@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在prepare返回之前不调用(不是yield)。为什么呢?

1 个答案:

答案 0 :(得分:0)

好像文档错了,我提交了一个错误。

https://github.com/tornadoweb/tornado/issues/1933