Allow all listener methods to terminate stream by returning false.
authorJosh Roesslein <jroesslein@gmail.com>
Thu, 3 Sep 2009 17:41:55 +0000 (12:41 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Thu, 3 Sep 2009 17:41:55 +0000 (12:41 -0500)
tweepy/streaming.py

index f955118aa43863a810d8498f3c1fae5752871346..50ec049c0e612b7d1bb4328e8ca191c77d656064 100644 (file)
@@ -119,12 +119,15 @@ class Stream(object):
       # turn json data into status object
       if 'in_reply_to_status_id' in data:
         status = parse_status(data, self.api)
-        self.listener.on_status(status)
+        if self.listener.on_status(status) == False:
+          self.running = False
       elif 'delete' in data:
         delete = json.loads(data)['delete']['status']
-        self.listener.on_delete(delete['id'], delete['user_id'])
+        if self.listener.on_delete(delete['id'], delete['user_id']) == False:
+          self.running = False
       elif 'limit' in data:
-        self.listener.on_limit(json.loads(data)['limit']['track'])
+        if self.listener.on_limit(json.loads(data)['limit']['track']) == False:
+          self.running = False
 
   def firehose(self, count=None, ):
     if self.running: