pycurlを使用してTwitterストリーミングAPIに接続しています。
これはうまく機能しますが、数時間実行した後、例外をスローせずに、ハングが無期限に停止する場合があります。このスクリプトでハングを検出/処理するにはどうすればよいですか?
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()