Discord-RPC
Discord-RPC copied to clipboard
Program hangs sometimes if discord has been in system tray for a long time.
I have been facing this issue intermittently and the only common factor I have managed to find is that it happens when Discord is closed (ie, in the system tray) for a long time.
I managed to isolate the problem to this line https://github.com/Senophyx/Discord-RPC/blob/main/discordrpc/presence.py#L160
enc_header += self.socket.read(header_size)
It seems like when Discord is closed for a long time, the socket enters hibernation and doesn't respond to the request and because of that, the program effectively hangs, waiting for a response.
It can be fixed by opening Discord (from the system tray) but that seems very un-intuitive for end user.
Is there a way to trigger a TimeOut event or something to check if the connection is live?