finish tweetstream update to 1.0 and add a way to stop the loop without killing the process
--- a/script/lib/tweetstream/tweetstream/streamclasses.py Fri Jul 01 18:59:48 2011 +0200
+++ b/script/lib/tweetstream/tweetstream/streamclasses.py Mon Jul 04 10:44:39 2011 +0200
@@ -10,9 +10,8 @@
class BaseStream(object):
"""A network connection to Twitters streaming API
- :param username: Twitter username for the account accessing the API.
- :param password: Twitter password for the account accessing the API.
- :keyword count: Number of tweets from the past to get before switching to
+ :param auth: tweepy auth object.
+ :keyword catchup: Number of tweets from the past to get before switching to
live stream.
:keyword url: Endpoint URL for the object. Note: you should not
need to edit this. It's present to make testing easier.
@@ -69,6 +68,8 @@
self.rate = 0
self.user_agent = USER_AGENT
if url: self.url = url
+
+ self.muststop = False
def __iter__(self):
return self
@@ -123,6 +124,9 @@
"""Return the next available tweet. This call is blocking!"""
while True:
try:
+ if self.muststop:
+ raise StopIteration()
+
if not self.connected:
self._init_conn()