I have a specific HTTP server that accepts incoming connection and keeps it opened, send data from time to time, like chat messages.
I tried to use the following code:
#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-
import urllib2
url = "http://localhost/chat"
if __name__ == "__main__":
for line in urllib2.urlopen(url):
print line
That should print chat messages as soon as they arrive until user terminate the script. In fact this script waits 1 minute, than prints every message arrived during this minute, and exit.
Is there a way to force python to keep connection opened and print received data immediately?