From: Jan-Pascal van Best Date: Thu, 18 Feb 2016 20:48:54 +0000 (+0100) Subject: Exit streamrunner when twitter api keys not specified or not correct; make runstream... X-Git-Tag: v1.1 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fupstream;p=tweet-django-debian Exit streamrunner when twitter api keys not specified or not correct; make runstream.py executable --- diff --git a/runstream.py b/runstream.py old mode 100644 new mode 100755 diff --git a/tweet/streamrunner.py b/tweet/streamrunner.py index 0b75fe3..8063a87 100644 --- a/tweet/streamrunner.py +++ b/tweet/streamrunner.py @@ -37,6 +37,10 @@ class Streamer(TwythonStreamer): def on_error(self, status_code, data): logger.info("Stream error: {}, {}".format(status_code, data)) + if status_code == 401: + logger.error("Twitter authentication error, bailing out...") + time.sleep(10) + close_stream() if status_code == 420: logger.warning("Stream rate limited, sleeping for 90 seconds...") time.sleep(90)