From fa1840c0fb91a3ac8ff48b37bbe78f63623397ec Mon Sep 17 00:00:00 2001 From: kjwon15 Date: Sat, 25 Nov 2017 02:45:47 +0900 Subject: Implement is_alive to async stream --- mastodon/Mastodon.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mastodon') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 88f4906..1802cd1 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -1305,10 +1305,14 @@ class Mastodon: class __stream_handle(): def __init__(self, connection): self.connection = connection + self._thread = threading.current_thread() def close(self): self.connection.close() + def is_alive(self): + return self._thread.is_alive() + def _threadproc(self): with closing(connection) as r: try: -- cgit v1.2.3 From 3faf7c6473ab22dd98b53fcecfd0b7e772aa8699 Mon Sep 17 00:00:00 2001 From: kjwon15 Date: Sat, 25 Nov 2017 03:09:38 +0900 Subject: Get current thread correctly --- mastodon/Mastodon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mastodon') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 1802cd1..3eb2cd7 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -1305,7 +1305,6 @@ class Mastodon: class __stream_handle(): def __init__(self, connection): self.connection = connection - self._thread = threading.current_thread() def close(self): self.connection.close() @@ -1314,6 +1313,7 @@ class Mastodon: return self._thread.is_alive() def _threadproc(self): + self._thread = threading.current_thread() with closing(connection) as r: try: listener.handle_stream(r.iter_lines()) -- cgit v1.2.3