fix: guard fcntl.flock(LOCK_UN) against OSError in cleanup blocks - #35793
Open
annguyenNous wants to merge 1 commit into
Open
fix: guard fcntl.flock(LOCK_UN) against OSError in cleanup blocks#35793annguyenNous wants to merge 1 commit into
annguyenNous wants to merge 1 commit into
Conversation
Two locations had unguarded fcntl.flock(LOCK_UN) calls that could raise OSError (e.g. EBADF), preventing proper cleanup: - agent/google_oauth.py:229 — OSError from flock was not caught, skipping the msvcrt fallback on Windows and propagating up. Added OSError to the existing except clause. - hermes_cli/kanban_db.py:1171 — OSError from flock skipped the handle.close() in the outer finally block, leaking the file descriptor. Wrapped in try/except OSError: pass. Five other flock(LOCK_UN) locations already had proper guards (shell_hooks.py, skill_usage.py, memory_tool.py, file_sync.py, auth.py).
Collaborator
tonydwb
reviewed
May 31, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary — PR #35793
Verdict: Comment (Duplicate label — may conflict with another fix)
Author: annguyenNous | Type: bugfix | Files: agent/google_oauth.py, hermes_cli/kanban_db.py
Findings
- Clean, targeted fix: adds
OSErrorto the existingexcept ImportErroringoogle_oauth.py:229, and wrapskanban_db.py:1171intry/except OSError: pass. - The PR correctly identifies 5 other locations that already have proper guards — no scope creep.
⚠️ Note: This PR is labeledduplicate. The fix is correct but may overlap with another PR. If this one lands, the code is correct as written. Verify it's not duplicating an already-merged fix before merging.
Reviewed by Hermes Agent
Contributor
|
Thanks for the focused cleanup. The original two-hunk patch is stale, but one related cleanup path remains worth salvaging. Problems
Suggested changes
This is an automated hermes-sweeper review. |
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.
Fix: Guard
fcntl.flock(LOCK_UN)againstOSErrorin cleanup blocksTwo locations had unguarded
fcntl.flock(LOCK_UN)calls that could raiseOSError(e.g.EBADFif the fd was already closed), preventing proper cleanup:agent/google_oauth.py:229OSErrorfromflock()was not caught — theexceptonly handledImportError(for platforms withoutfcntl). AnOSErrorwould skip themsvcrtfallback entirely and propagate up.Fix: Added
OSErrorto the existingexcept ImportErrorclause.hermes_cli/kanban_db.py:1171OSErrorfromflock()would skip thehandle.close()in the outerfinallyblock, leaking the file descriptor.Fix: Wrapped in
try/except OSError: pass.Already-guarded locations (no change needed)
5 other
flock(LOCK_UN)locations already had propertry/except (OSError, IOError): passguards:agent/shell_hooks.py:636tools/skill_usage.py:91tools/memory_tool.py:234tools/environments/file_sync.py:293hermes_cli/auth.py:1012