Skip to content

Commit

Permalink
Use 1h for ratelimit check (#2332)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Dec 5, 2021
1 parent 8721050 commit 30eff09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 79 deletions.
18 changes: 8 additions & 10 deletions custom_components/hacs/tasks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ def task_logger(self, handler: Handler, msg: str) -> None:
async def execute_task(self, *_, **__) -> None:
"""Execute the task defined in subclass."""
if not self._can_run_disabled and self.hacs.system.disabled:
self.log.warning(
"HacsTask<%s> Skipping task, HACS is disabled - %s",
self.slug,
self.hacs.system.disabled_reason,
self.task_logger(
self.log.debug,
f"Skipping task, HACS is disabled {self.hacs.system.disabled_reason}",
)
return
self.log.info("HacsTask<%s> Executing task", self.slug)
self.task_logger(self.log.debug, "Executing task")
start_time = timer()

try:
Expand All @@ -54,11 +53,10 @@ async def execute_task(self, *_, **__) -> None:
elif task := getattr(self, "async_execute", None):
await task() # pylint: disable=not-callable
except BaseException as exception: # pylint: disable=broad-except
self.log.error("HacsTask<%s> failed: %s", self.slug, exception)
self.task_logger(self.log.error, f"failed: {exception}")

else:
self.log.debug(
"HacsTask<%s> took " "%.2f seconds to complete",
self.slug,
timer() - start_time,
self.task_logger(
self.log.debug,
f"took {str(timer() - start_time)[:5]} seconds to complete",
)
2 changes: 1 addition & 1 deletion custom_components/hacs/tasks/check_ratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Task(HacsTask):
""" "Hacs task base."""

_can_run_disabled = True
schedule = timedelta(minutes=15)
schedule = timedelta(hours=1)

async def async_execute(self) -> None:
"""Execute the task."""
Expand Down
24 changes: 0 additions & 24 deletions custom_components/hacs/tasks/hello_world.py

This file was deleted.

44 changes: 0 additions & 44 deletions tests/tasks/test_hello_world.py

This file was deleted.

0 comments on commit 30eff09

Please sign in to comment.