For http persistent connection I wrote the following code:
waiters = set()
for x in LongPolling.waiters:
logging.warning("Connection closed *********")
if __name__ == "__main__":
application = tornado.web.Application([
I am braodcasting every time a new connection comes.. But the problem with this is, immediately after
get() the connection closes.
So how do I let the connection open after a get() call?
There is no such thing as a "persistent" http connection. the
Connection: keep-alive header permits client and server to perform a new http request/response cycle without creating a new underlying tcp connection, to save a bit of network traffic, but that is not visible to the application; and usually implemented in the server side by a reverse proxy. clients will have to make new requests when they receive responses to their GET's.
If that's not what you had in mind, just that you want to respond to requests a bit at a time, then you might be looking for
tornado.web.asynchronous. Note however, that most in-browser clients won't benefit from this very much; XHR's for instance won't be fired until the response completes, so browser applications will have to start a new request anyway