Search code examples
pythontornado

Python tornado stream request body


The documentation (http://www.tornadoweb.org/en/stable/web.html#tornado.web.stream_request_body) is writen that 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. But if I try

@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 do not called before prepare returns (not yield). Why?


Solution

  • Seems like the documentation is wrong, I've filed a bug.

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