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:
committed by
Xubin Ren
co-authored by
Cursor
parent
75c2506c07
commit
9a9e446f3f
+12
-6
@@ -14,7 +14,14 @@ from typing import Any, Callable, Coroutine, Literal
|
|||||||
from filelock import FileLock
|
from filelock import FileLock
|
||||||
from loguru import logger
|
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:
|
def _now_ms() -> int:
|
||||||
@@ -387,11 +394,10 @@ class CronService:
|
|||||||
|
|
||||||
async def _on_timer(self) -> None:
|
async def _on_timer(self) -> None:
|
||||||
"""Handle timer tick - run due jobs."""
|
"""Handle timer tick - run due jobs."""
|
||||||
loaded = self._load_store()
|
self._load_store()
|
||||||
# If a hot reload found a corrupt store on disk, ``loaded`` is
|
# If a hot reload found a corrupt store on disk, ``self._store`` may
|
||||||
# ``None`` but ``self._store`` may still hold the previous,
|
# still hold the previous, known-good in-memory snapshot. Keep using
|
||||||
# known-good in-memory snapshot. Keep using it rather than
|
# it rather than crashing the timer or wiping live jobs.
|
||||||
# crashing the timer or wiping live jobs.
|
|
||||||
if not self._store:
|
if not self._store:
|
||||||
self._arm_timer()
|
self._arm_timer()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ jobs.json + don't silently overwrite corrupt store``.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import time
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|||||||
Reference in New Issue
Block a user