fix: guard fcntl.flock(LOCK_UN) in cron tick and file_sync teardown#15553
Open
vominh1919 wants to merge 2 commits into
Open
fix: guard fcntl.flock(LOCK_UN) in cron tick and file_sync teardown#15553vominh1919 wants to merge 2 commits into
vominh1919 wants to merge 2 commits into
Conversation
…m providers Fixes: - NousResearch#13766: CLI agents no longer emit MEDIA:/path tags (CLI has no attachment channel) - NousResearch#13765: Add 'from __future__ import annotations' to 64 files for Python 3.9 PEP-604 compatibility - NousResearch#13764: Model switch now searches custom_providers catalog before API probe Changes: - agent/prompt_builder.py: Extend CLI platform hint to prevent MEDIA: tag emission - cli.py: Load custom_providers unconditionally (not just for picker) - hermes_cli/model_switch.py: Add _find_model_in_custom_providers() helper, insert step c2 in PATH B - hermes_cli/models.py: normalize_provider() handles custom:* slugs - 64 files: Add 'from __future__ import annotations' for Python 3.9 compatibility
fcntl.flock(LOCK_UN) in the finally block was not wrapped in try/except. If the unlock raises (e.g. on NFS or an invalid fd), lock_fd.close() is never reached, leaking the fd and leaving the lock file permanently locked — blocking all future cron ticks. The msvcrt branch already had this guard; apply the same pattern to the fcntl branch for consistency.
This was referenced Apr 26, 2026
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.
Problem
fcntl.flock(LOCK_UN)in thefinallyblock ofcron/scheduler.py:tick()andtools/environments/file_sync.py:_sync_back_locked()is not wrapped intry/except. If the unlock raises (e.g. on NFS, or if the fd became invalid):lock_fd.close()is never reached → fd leakThe
msvcrtbranch already had this guard; thefcntlbranch was simply an oversight.Fix
Wrap
fcntl.flock(LOCK_UN)intry/except (OSError, IOError): pass, matching the msvcrt pattern.Files changed
cron/scheduler.py— tick() finally blocktools/environments/file_sync.py— _sync_back_locked() finally block