Handle transient worker-options file absence during parallel startup - #21977
Closed
Shoryamishra61 wants to merge 3 commits into
Closed
Shoryamishra61 wants to merge 3 commits into
Shoryamishra61 wants to merge 3 commits into
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
🟡 Changes recommended
The retry helper can sleep beyond its advertised timeout when the interval exceeds the remaining budget.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR adds bounded retries for transient worker-options file absence during parallel startup.
Changes:
- Retries
FileNotFoundErrorwhile reading worker options. - Preserves immediate propagation of other errors.
- Adds deterministic retry and serialization tests.
File summaries
| File | Summary |
|---|---|
mypy/test/testworker.py |
Adds coverage for retry, timeout, error propagation, corruption, and serialization behavior. |
mypy/build_worker/worker.py |
Implements options-file retry handling. Moderate issue: sleep must be capped by the remaining timeout. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Member
|
Superseded by other PRs. |
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
When parallel type checking is enabled (
--num-workers > 0), build workers can intermittently fail during startup with:The reported failures show that workers can intermittently observe the options file as absent during startup. The exact underlying filesystem/process timing mechanism has not been established, but the worker currently treats even a transient
FileNotFoundErroras fatal.Root Cause & Context
PR #21306 serialized build options to
.mypy_cache/.worker_options.<build_id>.datato avoid command-line argument limits with large configurations (#21305). The coordinator already usesWORKER_START_TIMEOUT/WORKER_START_INTERVALwhile waiting for a worker to publish its status file, but the worker's initial options-file read currently has no tolerance for temporary absence.Fix
mypy/build_worker/worker.py, introduce aread_options_datahelper that adds a bounded retry only forFileNotFoundErrorusing the existingWORKER_START_TIMEOUTandWORKER_START_INTERVALdefaults.FileNotFoundErroris retried; unrelated OS errors (such asPermissionError) and deserialization corruption propagate immediately.FileNotFoundErroris re-raised.Tests
mypy/test/testworker.pycovering:sleepis not called).timeout=0failure without sleep.PermissionErrorwithout retry.Optionsserialization.python runtests.py testCheckingStubPackagesWorksInParallelModepytest -n0 mypy/test/testcmdline.py -k "Parallel"python runtests.py selfpython runtests.py lintFixes #21974