fix(cron): clean persistence lint issues

Keep the cron persistence hardening clean under ruff without changing behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Xubin Ren
2026-05-04 00:16:39 +08:00
committed by Xubin Ren
co-authored by Cursor
parent 75c2506c07
commit 9a9e446f3f
2 changed files with 12 additions and 7 deletions
+12 -6
View File
@@ -14,7 +14,14 @@ from typing import Any, Callable, Coroutine, Literal
from filelock import FileLock
from loguru import logger
from nanobot.cron.types import CronJob, CronJobState, CronPayload, CronRunRecord, CronSchedule, CronStore
from nanobot.cron.types import (
CronJob,
CronJobState,
CronPayload,
CronRunRecord,
CronSchedule,
CronStore,
)
def _now_ms() -> int:
@@ -387,11 +394,10 @@ class CronService:
async def _on_timer(self) -> None:
"""Handle timer tick - run due jobs."""
loaded = self._load_store()
# If a hot reload found a corrupt store on disk, ``loaded`` is
# ``None`` but ``self._store`` may still hold the previous,
# known-good in-memory snapshot. Keep using it rather than
# crashing the timer or wiping live jobs.
self._load_store()
# If a hot reload found a corrupt store on disk, ``self._store`` may
# still hold the previous, known-good in-memory snapshot. Keep using
# it rather than crashing the timer or wiping live jobs.
if not self._store:
self._arm_timer()
return
-1
View File
@@ -9,7 +9,6 @@ jobs.json + don't silently overwrite corrupt store``.
from __future__ import annotations
import json
import time
from pathlib import Path
import pytest