Add Stream.on_disconnect method
authorHarmon <Harmon758@gmail.com>
Sun, 24 Jan 2021 14:46:02 +0000 (08:46 -0600)
committerHarmon <Harmon758@gmail.com>
Sun, 24 Jan 2021 14:46:57 +0000 (08:46 -0600)
Resolves #277

tweepy/streaming.py

index 6e1a0db6bdffd69ff9da9652e00219c860bf84e8..7cd150e80b108d42543d7f0f27d5c8c749495a3f 100644 (file)
@@ -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")