Repository navigation
Parallel downloads into the same pooch cache - #381
Merged
Merged
Conversation
pooch (at least up to 1.9.0) creates the directory of a file it downloads without exist_ok, so when several processes download into the same cache, one fails if another creates the directory at the same time (fatiando/pooch#555, open fix in fatiando/pooch#554). On Windows the error is "[WinError 183] Cannot create a file when that file already exists". The registries now fetch through pooch_fetch(), which creates the directory first, with exist_ok. The new test downloads 100 files into new directories from a local HTTP server with 8 processes: without the workaround, some downloads fail in every run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Trying to add a second mccode-antlr notebook for the NCrystal example notebook website caused a CI failure which was tracked down to a race condition in the cache dir creation. There is an open PR to fix this in pooch itself, but the workaround on the mccode-antlr side is trivial, so would be nice to have it added here already.
Claude says:
When several processes download into the same pooch cache (e.g. two notebooks or test jobs running at the same time), one of them can fail when both need a component directory which does not exist yet. pooch (at least up to 1.9.0) creates the directory of a downloaded file without
exist_ok, so the slower process fails. On Windows it shows up as:This is a known pooch bug (fatiando/pooch#555), fixed upstream by the pooch PR fatiando/pooch#554, which is not merged yet. Until a pooch release contains it, the registries now fetch through a small helper,
pooch_fetch(), which first creates the directory itself, withexist_ok. The helper can be removed again once mccode-antlr requires a pooch version with that fix, but it is fine to simply keep it.The new test downloads 100 files into new directories with 8 processes from a local HTTP server, so it needs no network and takes about a second. Without the workaround it failed in every run (also on Linux).
🤖 Generated with Claude Code