From 0bf1ca204626aaefac847993eefd426ed2a4d1b3 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sun, 24 Jan 2021 08:46:02 -0600 Subject: [PATCH] Add Stream.on_disconnect method Resolves #277 --- tweepy/streaming.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 6e1a0db..7cd150e 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -127,6 +127,7 @@ class Stream: finally: self.session.close() self.running = False + self.on_disconnect() def _threaded_connect(self, *args, **kwargs): self.thread = Thread(target=self._connect, name="Tweepy Stream", @@ -200,6 +201,10 @@ class Stream: """Called when stream connection errors or times out""" log.error("Stream connection has errored or timed out") + def on_disconnect(self): + """Called when the stream has disconnected""" + log.info("Stream disconnected") + def on_exception(self, exception): """Called when an unhandled exception occurs.""" log.exception("Stream encountered an exception") -- 2.25.1