PetterKraabol / Twitch-Python

Object-oriented Twitch API for Python developers
https://pypi.org/project/twitch-python
MIT License
214 stars 37 forks source link

IRC thread fails silently on network issues. #45

Open Julian-O opened 2 years ago

Julian-O commented 2 years ago

In Python, if a thread's run() method raises an unhandled exception, it is silently ignored, and the thread terminates - unless another thread joins it, or an excepthook is defined.

irc.py defines the IRC thread.

It doesn't handle any exceptions during connection. It doesn't handle any exceptions during authentication. The only exception it handles during normal communications is IOError, and its only response to that is to silently terminate the thread.

Further, this thread object is created in Chat, which offers no method for joining the thread. (Admittedly, the thread is publicly shared, so someone could dig in to the internals of the class to find it.)

The upshot is that if there are any networking issues, the Chat object stops receiving messages, without notice.

In practice, I am finding about 1 in 6 times, when I launch a Chat object, it is failing silently, and I never receive any messages.

I don't have a quick answer here - I imagine it involves joins and/or on_error() callbacks - but this is making the library unusable.

gcfrxbots commented 2 years ago

Im also having this issue, sad to see we haven't seen any resolution thus far. I've found that the subscription doesn't return anything for on_error or on_completed so it just sorta disappears entirely. Doesn't even seem to be a way to retry.

DustyJinx commented 1 year ago

Having this issue as well. I'm using twitch-python in combination with TwitchAPI. It goes completely unnoticed if the socket dies or if it's not connected anymore, unless you're trying to send a second message, then you get a BrokenPipeException. But other than that, nothing is handled or shown. Which I think is essential and needed.