-
Notifications
You must be signed in to change notification settings - Fork 683
Retry transient Windows atomic write failures #2603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
medisean
wants to merge
1
commit into
vllm-project:main
Choose a base branch
from
medisean:codex/retry-windows-atomic-writes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,25 @@ async def test_local_storage_initialization(self): | |||||||
| assert storage.base_path == Path(tmp_dir) | ||||||||
| assert storage.base_path.exists() | ||||||||
|
|
||||||||
| def test_write_retries_when_destination_is_temporarily_locked(self, monkeypatch, tmp_path): | ||||||||
| storage = LocalStorage(base_path=str(tmp_path)) | ||||||||
| target = tmp_path / "object" | ||||||||
| attempts = 0 | ||||||||
| real_replace = os.replace | ||||||||
|
|
||||||||
| def replace_with_transient_lock(source, destination): | ||||||||
| nonlocal attempts | ||||||||
| attempts += 1 | ||||||||
| if attempts == 1: | ||||||||
| raise PermissionError("destination is temporarily locked") | ||||||||
| return real_replace(source, destination) | ||||||||
|
|
||||||||
| monkeypatch.setattr(os, "replace", replace_with_transient_lock) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To ensure this test passes on non-Windows platforms (where
Suggested change
|
||||||||
| storage._write_file(target, storage._wrap_data("content")) | ||||||||
|
|
||||||||
| assert target.read_text() == "content" | ||||||||
| assert attempts == 2 | ||||||||
|
|
||||||||
| @pytest.mark.asyncio | ||||||||
| async def test_environment_variable_override(self): | ||||||||
| """Test that STORAGE_LOCAL_PATH environment variable is respected.""" | ||||||||
|
|
||||||||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On non-Windows platforms (like Linux/macOS), a
PermissionErrorduringos.replaceis typically a permanent permission issue (e.g., write permission denied) rather than a transient sharing violation. Retrying in these cases introduces unnecessary delays (up to 100ms) before raising the exception.We should restrict this retry behavior to Windows (
os.name == 'nt').Note:
_write_json_file(line 553) also usesos.replaceand could suffer from the same transient Windows failures. Consider extracting this retry logic into a shared helper function (e.g.,_safe_replace) so both_write_fileand_write_json_filecan reuse it.