Opt: Check game server maintenance after GUI update event

This commit is contained in:
LmeSzinc 2022-08-04 21:39:10 +08:00
parent e8bfd08eba
commit 821b1b3295

16
alas.py
View File

@ -429,6 +429,13 @@ class AzurLaneAutoScript:
failure_record = {}
while 1:
# Check update event from GUI
if self.stop_event is not None:
if self.stop_event.is_set():
logger.info("Update event detected")
logger.info(f"Alas [{self.config_name}] exited.")
break
# Check game server maintenance
self.checker.wait_until_available()
if self.checker.is_recovered():
# There is an accidental bug hard to reproduce
@ -438,15 +445,10 @@ class AzurLaneAutoScript:
del_cached_property(self, 'config')
logger.info('Server or network is recovered. Restart game client')
self.run('restart')
if self.stop_event is not None:
if self.stop_event.is_set():
logger.info("Update event detected")
logger.info(f"Alas [{self.config_name}] exited.")
break
# Get task
task = self.get_next_task()
# Init device and change server
_ = self.device
# Skip first restart
if is_first and task == 'Restart':
logger.info('Skip task `Restart` at scheduler start')