Repository navigation
Write the cached registry file atomically - #382
Conversation
GitHubRegistry wrote its cached registry file in place, so another process reading it at the same time could get an empty or truncated registry, or fail with "ValueError: not enough values to unpack". It is now written to a temporary file which is then renamed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When several processes download the same file, pooch moves each download into place with shutil.move, which on Windows falls back to copying onto the file when another process has already put it there, and fails with WinError 32 if a process has the file open at that moment. pooch_fetch now retries the fetch a few times, which then finds the finished file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@g5t Claude had a look at that spurious test failure, the proposed solution is added to this PR in a second commit. Claude says: As discussed, the second commit fixes the failure of pooch downloads to a temporary file and moves it into place with
|
|
Claude also privately admitted to me: Since the race is intermittent, one green Windows run doesn't prove much. If the test still fails occasionally after this, I'll need to look again. |
|
well, that worry was premature claude :-) |
On Windows, opening the registry file can fail with PermissionError while another process replaces it with its own copy, as seen in test_parallel_registry_file. The read is now retried a few times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude fixed the new failure as well, probably. Claude: The Windows 3.14 job then failed in the new |
Another small potential race condition spotted in our new CI. Fix looks simple enough.
Claude says:
GitHubRegistrywrote its cached registry file in place. When several processes create the same registry at the same time (e.g. two notebooks run in parallel with an empty cache), one of them can read the file while another is writing it, and gets an empty or truncated registry, or fails with:The file is now written to a temporary file which is then renamed, as the in-memory registries already do. If the rename fails (on Windows, while another process is reading the file), the temporary file is dropped, since the other process wrote the same content.
The new test creates the same registry (20,000 entries) with 8 processes at once, 5 times, and takes about a second. Without the fix it fails in every run.
🤖 Generated with Claude Code