# HG changeset patch # User Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com> # Date 1309769079 -7200 # Node ID b3091d5aa6cc5a437fb505db64ec8026f98f3dc1 # Parent a1f49175effc85f2f9c5b9364d7b43bac0f62295 finish tweetstream update to 1.0 and add a way to stop the loop without killing the process diff -r a1f49175effc -r b3091d5aa6cc 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()