Skip to content

Commit

Permalink
Add: more strict failure check for restart sensitive tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
guoh064 committed Aug 29, 2024
1 parent 6f586b0 commit 2aec6c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions alas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from module.logger import logger
from module.notify import handle_notify

RESTART_SENSITIVE_TASKS = ['OpsiObscure', 'OpsiAbyssal', 'OpsiCrossMonth']


class AzurLaneAutoScript:
stop_event: threading.Event = None
Expand Down Expand Up @@ -542,8 +544,8 @@ def loop(self):
failed = deep_get(self.failure_record, keys=task, default=0)
failed = 0 if success else failed + 1
deep_set(self.failure_record, keys=task, value=failed)
if failed >= 3:
logger.critical(f"Task `{task}` failed 3 or more times.")
if failed >= 3 or failed >= 1 and task in RESTART_SENSITIVE_TASKS:
logger.critical(f"Task `{task}` failed {failed} or more times.")
logger.critical("Possible reason #1: You haven't used it correctly. "
"Please read the help text of the options.")
logger.critical("Possible reason #2: There is a problem with this task. "
Expand All @@ -552,7 +554,7 @@ def loop(self):
handle_notify(
self.config.Error_OnePushConfig,
title=f"Alas <{self.config_name}> crashed",
content=f"<{self.config_name}> RequestHumanTakeover\nTask `{task}` failed 3 or more times.",
content=f"<{self.config_name}> RequestHumanTakeover\nTask `{task}` failed {failed} or more times.",
)
exit(1)

Expand Down

0 comments on commit 2aec6c4

Please sign in to comment.