From eb336a30c2ef04c2b0f66727de1bc585ad96e2da Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Tue, 17 Apr 2018 14:59:45 +0200 Subject: Add is_receiving: --- mastodon/Mastodon.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 595b79e..3706008 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -1716,6 +1716,7 @@ class Mastodon: self.connect_func = connect_func self.reconnect_async = reconnect_async self.reconnect_async_wait_sec = reconnect_async_wait_sec + self.reconnecting = False def close(self): self.closed = True @@ -1724,6 +1725,12 @@ class Mastodon: def is_alive(self): return self._thread.is_alive() + def is_receiving(self): + if self.closed or not self.running or self.reconnecting or not self.is_alive(): + return False + else: + return True + def _threadproc(self): self._thread = threading.current_thread() @@ -1741,6 +1748,7 @@ class Mastodon: # Reconnect loop. Try immediately once, then with delays on error. if self.reconnect_async and not self.closed: + self.reconnecting = True connect_success = False while not connect_success: connect_success = True @@ -1752,7 +1760,7 @@ class Mastodon: except: time.sleep(self.reconnect_async_wait_sec) connect_success = False - + self.reconnecting = False else: self.running = False return 0 -- cgit v1.2.3