Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
ecdc8b54
Commit
ecdc8b54
authored
Sep 03, 2009
by
Josh Roesslein
Browse files
Added on_timeout() to stream listener.
parent
cc3f9a4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
streamwatcher.py
View file @
ecdc8b54
...
...
@@ -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: '
)
...
...
tweepy/streaming.py
View file @
ecdc8b54
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment