Skip to content

Commit

Permalink
Test wrap command function in a mutex
Browse files Browse the repository at this point in the history
to avoid race conditions with the _command_offset
  • Loading branch information
dmunozv04 committed Sep 14, 2024
1 parent c56cbfe commit 39aef5b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/iSponsorBlockTV/ytlounge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
self.mute_ads = config.mute_ads
self.skip_ads = config.skip_ads
self.auto_play = config.auto_play
self._command_mutex = asyncio.Lock()

# Ensures that we still are subscribed to the lounge
async def _watchdog(self):
Expand Down Expand Up @@ -181,3 +182,9 @@ async def set_auto_play_mode(self, enabled: bool):

async def play_video(self, video_id: str) -> bool:
return await self._command("setPlaylist", {"videoId": video_id})

# Test to wrap the command function in a mutex to avoid race conditions with
# the _command_offset (TODO: move to upstream if it works)
async def _command(self, command: str, command_parameters: dict = None) -> bool:
async with self._command_mutex:
return await super()._command(command, command_parameters)

0 comments on commit 39aef5b

Please sign in to comment.