Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 1h for ratelimit check #2332

Merged
merged 1 commit into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.