fix(memory): support Windows memory file locking - #8563
Closed
XiaoXiao0221 wants to merge 1 commit into
Closed
Conversation
19 tasks
Contributor
Author
|
A few reviewer-facing notes for context:
|
This was referenced Apr 12, 2026
XiaoXiao0221
force-pushed
the
fix/memory-tool-windows-lock
branch
from
April 13, 2026 17:13
e3250b0 to
cdb0b6a
Compare
XiaoXiao0221
force-pushed
the
fix/memory-tool-windows-lock
branch
from
April 15, 2026 15:06
cdb0b6a to
0bc4b87
Compare
Contributor
|
Thanks for the contribution, @XiaoXiao0221! Closing this as a duplicate of #6479 (by @iacker), which targets the same fix/feature. We're consolidating on that PR for review. If you want to help push it over the line, please jump in there — or if you think your approach is better for a specific reason that isn't covered in the other PR, let us know and we can reopen. |
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.
What does this PR do?
This fixes a Windows compatibility bug in
tools/memory_tool.py.On
main, the memory tool still importsfcntlunconditionally, which prevents the tool from loading on Windows. This revision keeps Unix behavior onfcntl, adds a Windows lock path viamsvcrt, and preserves retry/timeout handling so concurrent writers do not fail immediately.The Windows lock path also passes
msvcrt.locking()an integer file descriptor from the lock file handle. Without that, memory mutations can fail at runtime withTypeError: '_io.TextIOWrapper' object cannot be interpreted as an integer.Related Issue
No linked issue.
Type of Change
Changes Made
fcntlandmsvcrtintools/memory_tool.pyfcntl.flock()msvcrt.locking()with retry + timeout behaviormsvcrt.locking()instead of a file objectHow to Test
pytest tests/tools/test_memory_tool.py -qhermesand verify it no longer logsCould not import tool module tools.memory_tool: No module named 'fcntl'add -> reload -> removeand confirm writes succeed across sessionsChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
pytest tests/tools/test_memory_tool.py -q->37 passedMemoryStore-> all succeededhermesno longer emitsCould not import tool module tools.memory_tool: No module named 'fcntl'pytest tests/ -x -vvon Windows still fails during collection intests/hermes_cli/test_gateway_service.pybecause it imports the Unix-onlypwdmodule (ModuleNotFoundError: No module named 'pwd')