Skip to content

Commit

Permalink
Fix issues with concurrent downloads (#2542)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Mar 5, 2022
1 parent e5b516d commit 47261b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion custom_components/hacs/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
PACKAGE_NAME = "custom_components.hacs"

DEFAULT_CONCURRENT_TASKS = 15
DEFAULT_CONCURRENT_BACKOFF_TIME = 0
DEFAULT_CONCURRENT_BACKOFF_TIME = 1

PLATFORMS = ["sensor"]

Expand Down
7 changes: 3 additions & 4 deletions custom_components/hacs/utils/queue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
class QueueManager:
"""The QueueManager class."""

running = False
queue: list[Coroutine] = []

def __init__(self, hass: HomeAssistant) -> None:
self.hass = hass
self.queue: list[Coroutine] = []
self.running = False

@property
def pending_tasks(self) -> int:
Expand All @@ -38,7 +37,7 @@ def clear(self) -> None:

def add(self, task: Coroutine) -> None:
"""Add a task to the queue."""
self.queue.append(self.hass.loop.create_task(task))
self.queue.append(task)

async def execute(self, number_of_tasks: int | None = None) -> None:
"""Execute the tasks in the queue."""
Expand Down

0 comments on commit 47261b5

Please sign in to comment.