Open FabioGNR opened 6 months ago
I faced this issue and sort of sorted it by calling refresh_auth
every 24 hours. Implementation can be seen here:
https://github.com/dmunozv04/iSponsorBlockTV/blob/80196b19aade6041ddf75c46f97ff885715b55fc/src/iSponsorBlockTV/main.py#L35
Is this a race condition with command_offset?
self._command_offset
by using an asyncio.Lock
._command
method is called concurrently by multiple async tasks.self._command_offset
at a time.Thank you for your comment and helping!
Sadly I believe the reproduction described in this issue should not be related to this; it occurs even when no commands are issued and there's only one active coroutine.
I think the self._command_offset
variable is safely updated and read; there's no await in between.
But since the self.session.post
call does await when entering the context manager it's possible that the commands are issued out of order. I will experiment with this and see if the lock effectively solves it.
As a general note: with multiple threads this will also cause issues. At this time it's not something I consider as supported by the library though.
Using code that continually reconnects and refreshes authorization, eventually the real connection to the lounge session is lost. Instead a sort of phantom session becomes active, where no events are being sent, but there's no errors from the API. Calling
refresh_auth
usually fixes this situation, however it should automatically be detected and prevented.The following sample code can be used to observe this:
In my experience it can take a few days or up to a week before this problem occurs, in this time the screen (and thus youtube app) is turned on/off a few times.