fix: record cancelled cron runs

maintainer edit: treat job-level CancelledError as a failed cron run so bound automation cancellations update run history and do not break subsequent scheduling.
This commit is contained in:
chengyongru committed 2026-06-11 22:01:23 +08:00
1 parent a326ba40f4
commit f82ab9f192
2 files changed
+34

No files matched your search

+7
View File
@@ -448,6 +448,13 @@ class CronService:
job.state.last_error = None
logger.info("Cron: job '{}' completed", job.name)
except asyncio.CancelledError as e:
current = asyncio.current_task()
if current is not None and current.cancelling():
raise
job.state.last_status = "error"
job.state.last_error = str(e) or e.__class__.__name__
logger.exception("Cron: job '{}' was cancelled", job.name)
except Exception as e:
job.state.last_status = "error"
job.state.last_error = str(e)