Answer the question
In order to leave comments, you need to log in
How does tornado.web.RequestHandler.flush work?
The server looks like this:
from tornado import ioloop, web, gen
class MainHandler(web.RequestHandler):
@gen.coroutine
def get(self):
self.write('1' * 1024)
self.flush(callback=(yield gen.Callback('flush')))
yield gen.Wait('flush')
print 'First chunk sent'
self.write('2' * 1024)
self.flush(callback=(yield gen.Callback('flush')))
yield gen.Wait('flush')
print 'Second chunk sent'
self.finish()
application = web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8000)
ioloop.IOLoop.instance().start()
import urllib2
urllib2.urlopen('http://127.0.0.1:8000/').close()
First chunk sent
Second chunk sent
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question