Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cron/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1889,8 +1889,9 @@ def tick(verbose: bool = True, adapters=None, loop=None) -> int:
try:
due_jobs = get_due_jobs()

if verbose and not due_jobs:
logger.info("%s - No jobs due", _hermes_now().strftime('%H:%M:%S'))
if not due_jobs:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main added an idle-path MCP orphan sweep after this PR branched (cron/scheduler.py:3735-3780). Returning here would skip that cleanup on every idle verbose=False gateway tick; preserve the sweep while avoiding load_config().

if verbose:
logger.info("%s - No jobs due", _hermes_now().strftime('%H:%M:%S'))
return 0

if verbose:
Expand Down
13 changes: 13 additions & 0 deletions tests/cron/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2584,3 +2584,16 @@ def fake_run_coro(coro, _loop):
# 2. Second file still got dispatched — one timeout doesn't abort the batch
adapter.send_video.assert_called_once()
assert adapter.send_video.call_args[1]["video_path"] == str(fast.resolve())


def test_tick_skips_config_load_when_no_jobs_due(tmp_path):
"""Idle cron ticks should return before config/home churn."""
from cron import scheduler as sched

with patch("cron.scheduler._hermes_home", tmp_path), \
patch("cron.scheduler.get_due_jobs", return_value=[]), \
patch("cron.scheduler.load_config") as mock_load_config:
result = sched.tick(verbose=False)

assert result == 0
mock_load_config.assert_not_called()
Loading