Closed bingen13 closed 5 years ago
Tootstream streaming gets messed up and drops if the connection is interrupted. I don't know if it's possible or feasible to extend a timeout to prevent hiccups.
We might be able to trap the exception so it doesn't crash the program all the way. But that would require also not trapping everything so actual errors get caught and suppressed.
Mastodon.py got an update to handle this here https://github.com/halcy/Mastodon.py/commit/d0ae9dcd055e3bdc96a5ab817d14cda012516297, you just need to add a parameter to the stream_* calls.
I've been using a branch with this for the past week, for 3 Mastodon instances (it definitely hasn't lasted this long before).
I'll make a PR.
PR made #192
Hi,
While using the streaming mode (stream home) I got this (sorry about the irregular wrapping):
---begin exception unwind--- Exception in thread Thread-1: Traceback (most recent call last): File "/home/david/.local/lib/python3.5/site-packages/urllib3/response.py", lin e 572, in _update_chunk_length self.chunk_left = int(line, 16) ValueError: invalid literal for int() with base 16: b''
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/david/.local/lib/python3.5/site-packages/urllib3/response.py", lin e 331, in _error_catcher yield File "/home/david/.local/lib/python3.5/site-packages/urllib3/response.py", lin e 637, in read_chunked self._update_chunk_length() File "/home/david/.local/lib/python3.5/site-packages/urllib3/response.py", lin e 576, in _update_chunk_length raise httplib.IncompleteRead(line) http.client.IncompleteRead: IncompleteRead(0 bytes read)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/david/.local/lib/python3.5/site-packages/requests/models.py", line 749, in generate for chunk in self.raw.stream(chunk_size, decode_content=True): File "/home/david/.local/lib/python3.5/site-packages/urllib3/response.py", lin e 461, in stream for line in self.read_chunked(amt, decode_content=decode_content): File "/home/david/.local/lib/python3.5/site-packages/urllib3/response.py", lin e 665, in read_chunked self._original_response.close() File "/usr/lib/python3.5/contextlib.py", line 77, in exit self.gen.throw(type, value, traceback) File "/home/david/.local/lib/python3.5/site-packages/urllib3/response.py", lin e 349, in _error_catcher raise ProtocolError('Connection broken: %r' % e, e) urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes re ad)', IncompleteRead(0 bytes read))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/david/.local/lib/python3.5/site-packages/mastodon/streaming.py", l ine 59, in handle_stream for chunk in response.iter_content(chunk_size = 1): File "/home/david/.local/lib/python3.5/site-packages/requests/models.py", line 752, in generate raise ChunkedEncodingError(e) requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/usr/lib/python3.5/threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "/home/david/.local/lib/python3.5/site-packages/mastodon/Mastodon.py", li ne 2082, in _threadproc raise e File "/home/david/.local/lib/python3.5/site-packages/mastodon/Mastodon.py", li ne 2079, in _threadproc listener.handle_stream(r) File "/home/david/.local/lib/python3.5/site-packages/mastodon/streaming.py", l ine 84, in handle_stream err File "", line 3, in raise_from
mastodon.Mastodon.MastodonNetworkError: Server ceased communication.
---end exception unwind---
Looks like there was a server issue and it caused a chain of uncaught or mishandled exceptions on tootstream. Just reporting in case it's useful.