Skip to content

fix: guard fcntl.flock(LOCK_UN) in cron tick and file_sync teardown#15553

Open
vominh1919 wants to merge 2 commits into
NousResearch:mainfrom
vominh1919:fix/cron-lock-unlock-guard
Open

fix: guard fcntl.flock(LOCK_UN) in cron tick and file_sync teardown#15553
vominh1919 wants to merge 2 commits into
NousResearch:mainfrom
vominh1919:fix/cron-lock-unlock-guard

Conversation

@vominh1919

Copy link
Copy Markdown
Contributor

Problem

fcntl.flock(LOCK_UN) in the finally block of cron/scheduler.py:tick() and tools/environments/file_sync.py:_sync_back_locked() is not wrapped in try/except. If the unlock raises (e.g. on NFS, or if the fd became invalid):

  1. lock_fd.close() is never reached → fd leak
  2. The lock file stays permanently locked → all future cron ticks are blocked

The msvcrt branch already had this guard; the fcntl branch was simply an oversight.

Fix

Wrap fcntl.flock(LOCK_UN) in try/except (OSError, IOError): pass, matching the msvcrt pattern.

Files changed

  • cron/scheduler.py — tick() finally block
  • tools/environments/file_sync.py — _sync_back_locked() finally block

…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.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management backend/file-sync File sync across remote backends labels Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/file-sync File sync across remote backends comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants