arngarden/TwitterStream — pull request #1 by trifle (2013-01-04 22:27:58+00:00)
Title: Add timeout option to catch dead connections

Hi Gustav,

thanks for putting your code on github!

I've added a timeout option to the script that should make it more reliable if the connection drops.
The ordinary TIMEOUT option of pycurl would simply kill the stream after a fixed amount of seconds which isn't what we want.

Instead, one can now pass a timeout value to TwitterStream(). If CURL receives less than 1 byte per second for the duration of "timeout" seconds, it raises an exception, causing a reset.

I should add that the newlines Twitter sends as keepalives are apparently NOT enough to keep CURL from triggering the reset, so this should probably only be used on high-volume streams.