Commit ecdc8b54 authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Added on_timeout() to stream listener.

parent cc3f9a4d
......@@ -14,6 +14,9 @@ class StreamWatcherListener(tweepy.StreamListener):
print 'An error has occured! Status code = %s' % status_code
return True # keep stream alive
def on_timeout(self):
print 'Snoozing Zzzzzz'
# Prompt for login credentials and setup stream object
username = raw_input('Twitter username: ')
password = getpass('Twitter password: ')
......
......@@ -37,6 +37,10 @@ class StreamListener(object):
"""Called when a non-200 status code is returned"""
return False
def on_timeout(self):
"""Called when stream connection times out"""
return
class Stream(object):
host = 'stream.twitter.com'
......@@ -80,7 +84,8 @@ class Stream(object):
error_counter = 0
self._read_loop(resp)
except timeout:
print 'timeout!'
if self.listener.on_timeout() == False:
break
if self.running is False:
break
conn.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment