mirror of
https://github.com/sui-feng-cb/AzurLaneAutoScript1.git
synced 2026-08-18 04:34:53 +08:00
Fix: harden DowntimeFetcher consistency checks, error boundary and fetch lock
This commit is contained in:
@@ -22,8 +22,7 @@ def parse_downtime(window: str) -> Optional[datetime]:
|
||||
window (str): Window string in format 'YYYY-MM-DD HH:MM~HH:MM'.
|
||||
|
||||
Returns:
|
||||
Optional[datetime]:
|
||||
End datetime parsed from the window, or None if no pattern matched.
|
||||
Optional[datetime]: End datetime parsed from the window, or None if no pattern matched.
|
||||
"""
|
||||
match = DOWNTIME_FORMAT_RE.search(window)
|
||||
if not match:
|
||||
@@ -38,8 +37,9 @@ def parse_downtime(window: str) -> Optional[datetime]:
|
||||
|
||||
def update_downtime(config: AzurLaneConfig, force_refresh=False) -> bool:
|
||||
"""Fetch downtime and write config."""
|
||||
logger.info('Fetch downtime')
|
||||
try:
|
||||
payload = DowntimeFetcher().run(force_refresh=force_refresh)
|
||||
payload = DowntimeFetcher(instance_name=config.config_name).run(force_refresh=force_refresh)
|
||||
except FetchError as e:
|
||||
# Expected operational failure degrade
|
||||
logger.warning(f'Failed to fetch downtime: {e}')
|
||||
@@ -75,6 +75,7 @@ def run_downtime_fetch(config: AzurLaneConfig):
|
||||
# Tool task entry is invoked with config bound to Alas by default,
|
||||
# rebind to DowntimeFetch.
|
||||
config.init_task('DowntimeFetch')
|
||||
logger.info(f'Downtime fetch start: server={config.SERVER} test_mode={config.DowntimeFetch_FetcherTest}')
|
||||
if config.DowntimeFetch_FetcherTest:
|
||||
DowntimeFetcherTest().run()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user