Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
queue backpressure
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveicedgreentea committed Apr 8, 2024
1 parent 9489a72 commit 91ac6fd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_components/jvc_projectors/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ async def update_worker(self):

# getter will be a Callable
try:
# queue backpressure
if self.command_queue.qsize() > 10:
# this allows the queue to process stuff without filling up
_LOGGER.debug("Queue is full, waiting to add attributes")
await asyncio.sleep(2)
continue
unique_id, getter, attribute = await self.attribute_queue.get()
# add to the command queue with a single interface
await self.command_queue.put((1, (unique_id, getter, attribute)))
Expand Down

0 comments on commit 91ac6fd

Please sign in to comment.