Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: exceptions must derive from BaseException #368

Open
TomCasavant opened this issue Feb 2, 2024 · 3 comments
Open

TypeError: exceptions must derive from BaseException #368

TomCasavant opened this issue Feb 2, 2024 · 3 comments

Comments

@TomCasavant
Copy link

This error popped up after the streaming api timed out

Traceback (most recent call last):
File "bot.py", line 49, in <module>
     '''
   File "bot.py", line 44, in stream_timeline
     if (not status['reblogged'] and self.is_post(status)):
   File "/usr/local/lib/python3.8/site-packages/decorator.py", line 232, in fun
     return caller(func, *(extras + args), **kw)
   File "/usr/local/lib/python3.8/site-packages/mastodon/utility.py", line 49, in wrapper
     return function(self, *args, **kwargs)
   File "/usr/local/lib/python3.8/site-packages/mastodon/streaming_endpoints.py", line 21, in stream_user
     return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
   File "/usr/local/lib/python3.8/site-packages/mastodon/internals.py", line 540, in __stream
     listener.handle_stream(r)
   File "/usr/local/lib/python3.8/site-packages/mastodon/streaming.py", line 151, in handle_stream
     six.raise_from(
   File "<string>", line 3, in raise_from
 TypeError: exceptions must derive from BaseException

just from glancing at mastodon/streaming.py it looks like the error it's throwing does derive from Exception so I'm not sure what would cause this

@halcy
Copy link
Owner

halcy commented Feb 11, 2024

That's quite weird. I can't repro it, either. Maybe some residual six weirdness. We're going to be removing that, so maybe in the newest version it will be fixed. Once that's out, maybe you can give it another shot?

@TomCasavant
Copy link
Author

I wasn't able to consistently reproduce it at the time but I'll give it a shot with the new version

@XaviArnaus
Copy link

Good morning,

I was able to reproduce it (in fact, I am receiving this error quite often). I am listening the stream_user endpoint and the server gets timed out. Then apparently six wants to complain and there we go.

Full traceback:

Traceback (most recent call last):
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/urllib3/response.py", line 737, in _error_catcher
    yield
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/urllib3/response.py", line 1184, in read_chunked
    self._update_chunk_length()
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/urllib3/response.py", line 1108, in _update_chunk_length
    line = self._fp.fp.readline()  # type: ignore[union-attr]
  File "/usr/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/requests/models.py", line 816, in generate
    yield from self.raw.stream(chunk_size, decode_content=True)
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/urllib3/response.py", line 1040, in stream
    yield from self.read_chunked(amt, decode_content=decode_content)
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/urllib3/response.py", line 1213, in read_chunked
    self._original_response.close()
  File "/usr/lib/python3.9/contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/urllib3/response.py", line 742, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.") from e  # type: ignore[arg-type]
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='**********', port=443): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/mastodon/streaming.py", line 109, in handle_stream
    for chunk in response.iter_content(chunk_size=1):
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/requests/models.py", line 822, in generate
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='**********'', port=443): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xavier/bots/feeder/mastofeed/runners/listener.py", line 33, in run
    mastodon_instance.stream_user(mention_listener)
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/mastodon/utility.py", line 49, in wrapper
    return function(self, *args, **kwargs)
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/mastodon/streaming_endpoints.py", line 21, in stream_user
    return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/mastodon/internals.py", line 540, in __stream
    listener.handle_stream(r)
  File "/home/xavier/.cache/pypoetry/virtualenvs/mastofeed-XHz1mY8R-py3.9/lib/python3.9/site-packages/mastodon/streaming.py", line 151, in handle_stream
    six.raise_from(
  File "<string>", line 3, in raise_from
TypeError: exceptions must derive from BaseException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants