fix: set APScheduler misfire_grace_time=None for reliable job execution#178
Open
sakhnenkoff wants to merge 1 commit intoRichardAtCT:mainfrom
Open
fix: set APScheduler misfire_grace_time=None for reliable job execution#178sakhnenkoff wants to merge 1 commit intoRichardAtCT:mainfrom
sakhnenkoff wants to merge 1 commit intoRichardAtCT:mainfrom
Conversation
With misfire_grace_time=300, heartbeats were still missed when the bot was busy for >5 minutes (observed: 8m54s miss). Setting to None guarantees every job fires exactly once, combined with coalesce=True to prevent duplicate execution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #175.
The
AsyncIOSchedulerinJobScheduler.__init__is created without explicitjob_defaults, meaning APScheduler uses its defaultmisfire_grace_time=1second. This is too strict for a bot where Claude command execution routinely takes minutes — any job that can't start within 1 second of its scheduled time is silently skipped.Changes:
misfire_grace_time=None— guarantees every job fires exactly once, regardless of how latecoalesce=True— merges multiple missed runs into a single execution, preventing duplicate firingThe worst case with this configuration is one late run, never a skipped one.
Tests
2 new tests in
tests/unit/test_scheduler/test_misfire_config.py:test_misfire_grace_time_is_none— verifies the config valuetest_coalesce_is_enabled— verifies coalesce is onAll existing tests continue to pass.