I am using pycurl to connect to the twitter streaming API.
This works well but sometimes after running for a few hours it will stop hang indefinitely, not throwing any exceptions. How can I detect/handle a hang in this script?
import pycurl, json
STREAM_URL = "http://stream.twitter.com/1/statuses/filter.json"
USER = "presidentskroob"
PASS = "12345"
def on_receive(data):
print data
conn = pycurl.Curl()
conn.setopt(pycurl.USERPWD, "%s:%s" % (USER, PASS))
conn.setopt(pycurl.URL, STREAM_URL)
conn.setopt(pycurl.WRITEFUNCTION, on_receive)
conn.perform()
FROM: http://man-wiki.net/index.php/3:curl_easy_setopt
and
Example: