aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2018-05-06 15:58:37 +0200
committerGitHub <[email protected]>2018-05-06 15:58:37 +0200
commit1a62b6a5a65179fc6e098b8029078197e114fc98 (patch)
tree98328e8776447334b19592992016d9b7f16ae98b /mastodon/streaming.py
parentfbd4122fec092bff6b1cc9f44dfeda6ee693c41b (diff)
parentca0ea36c6edd58dc15e5fd7f31f24ba5097d6e8d (diff)
downloadmastodon.py-1a62b6a5a65179fc6e098b8029078197e114fc98.tar.gz
Merge pull request #128 from codl/stream-timeout
add timeouts to streams
Diffstat (limited to 'mastodon/streaming.py')
-rw-r--r--mastodon/streaming.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mastodon/streaming.py b/mastodon/streaming.py
index 1c73f48..3fbd569 100644
--- a/mastodon/streaming.py
+++ b/mastodon/streaming.py
@@ -6,8 +6,8 @@ https://github.com/tootsuite/mastodon/blob/master/docs/Using-the-API/Streaming-A
6import json 6import json
7import six 7import six
8from mastodon import Mastodon 8from mastodon import Mastodon
9from mastodon.Mastodon import MastodonMalformedEventError, MastodonNetworkError 9from mastodon.Mastodon import MastodonMalformedEventError, MastodonNetworkError, MastodonReadTimeout
10from requests.exceptions import ChunkedEncodingError 10from requests.exceptions import ChunkedEncodingError, ReadTimeout
11 11
12class StreamListener(object): 12class StreamListener(object):
13 """Callbacks for the streaming API. Create a subclass, override the on_xxx 13 """Callbacks for the streaming API. Create a subclass, override the on_xxx
@@ -68,7 +68,12 @@ class StreamListener(object):
68 MastodonNetworkError("Server ceased communication."), 68 MastodonNetworkError("Server ceased communication."),
69 err 69 err
70 ) 70 )
71 71 except MastodonReadTimeout as err:
72 six.raise_from(
73 MastodonReadTimeout("Timed out while reading from server."),
74 err
75 )
76
72 def _parse_line(self, line, event): 77 def _parse_line(self, line, event):
73 if line.startswith(':'): 78 if line.startswith(':'):
74 self.handle_heartbeat() 79 self.handle_heartbeat()
Powered by cgit v1.2.3 (git 2.41.0)