constants.py 1.2 KB

12345678910111213141516171819202122
  1. """Fire-claim timing bounds shared by the job store and its siblings.
  2. Import-free on purpose: a sibling loaded fresh from a newer on-disk tree must resolve
  3. these without going through the ``cron.jobs`` object a long-lived process cached at boot.
  4. """
  5. # A fire_claim younger than this is a live run (heartbeat cadence is 60 s). One value
  6. # for claiming, one-shot re-arm, and stale-error recovery so they cannot disagree.
  7. FIRE_CLAIM_TTL_SECONDS = 300
  8. # A hosted/webhook fire for the armed slot can arrive a few seconds before the stored
  9. # ``next_run_at`` (the fire scheduler's clock runs ahead of ours). Claims that early still own
  10. # the slot; only claims further ahead are off-tick manual/dashboard fires.
  11. FIRE_CLAIM_SKEW_SECONDS = 60
  12. # Multiplier over HERMES_CRON_TIMEOUT for claim TTLs: the timeout is an *inactivity* limit, not a
  13. # wall-clock cap, so healthy runs may legitimately exceed it and a TTL of exactly the timeout
  14. # would expire live claims.
  15. CLAIM_TTL_INACTIVITY_HEADROOM = 3
  16. def is_recurring(job: dict) -> bool:
  17. """A cron/interval job (vs a one-shot); a null ``schedule`` counts as not recurring."""
  18. return (job.get("schedule") or {}).get("kind") in {"cron", "interval"}