From 2aec6c4758f66aa22d1d3c4c1708a932c54b3b85 Mon Sep 17 00:00:00 2001 From: guoh064 <50830808+guoh064@users.noreply.github.com> Date: Thu, 29 Aug 2024 13:22:55 +0800 Subject: [PATCH] Add: more strict failure check for restart sensitive tasks --- alas.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/alas.py b/alas.py index a525e272b5..9132c02f45 100644 --- a/alas.py +++ b/alas.py @@ -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 @@ -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. " @@ -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)