finish tweetstream update to 1.0 and add a way to stop the loop without killing the process
authorYves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Mon, 04 Jul 2011 10:44:39 +0200
changeset 209 b3091d5aa6cc
parent 208 a1f49175effc
child 210 ce76cecb5ca2
finish tweetstream update to 1.0 and add a way to stop the loop without killing the process
script/lib/tweetstream/tweetstream/streamclasses.py
--- 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()