From: Josh Roesslein Date: Thu, 3 Sep 2009 17:41:55 +0000 (-0500) Subject: Allow all listener methods to terminate stream by returning false. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cc3f9a4d12f2d30f807d836b17da6a8002070c32;p=tweepy.git Allow all listener methods to terminate stream by returning false. --- diff --git a/tweepy/streaming.py b/tweepy/streaming.py index f955118..50ec049 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -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: