Skip to content

fix(models): make model fetching safe under concurrent workers - #364

Merged
wpbonelli merged 1 commit into
MODFLOW-ORG:developfrom
wpbonelli:fix/concurrent-model-fetch
Sep 20, 2026
Merged

wpbonelli merged 1 commit into
MODFLOW-ORG:developfrom
wpbonelli:fix/concurrent-model-fetch

Conversation

@wpbonelli

Copy link
Copy Markdown
Member

Pooch can produce FileExistsError when concurrent workers (e.g. pytest-xdist) try to create the same new subdirectory. Create the directory first with exist_ok=True so pooch's existence check passes. See fatiando/pooch#554

Also place the lock file in the cache directory next to the zip file it protects, rather than in the cwd, so it excludes processes regardless of their working directory and does not litter it.

@wpbonelli wpbonelli added this to the 1.10.0 milestone Sep 20, 2026
@wpbonelli wpbonelli added the bug Something isn't working label Sep 20, 2026
Pooch creates a file's parent directory with a bare check-then-makedirs,
which raises FileExistsError when concurrent workers (e.g. pytest-xdist)
fetch into the same new subdirectory. Create the directory first with
exist_ok=True so pooch's existence check passes and it skips makedirs.

Also place the zip fetch lock in the cache directory next to the zip it
protects, rather than in the cwd, so it excludes processes regardless of
their working directory and does not litter it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@wpbonelli
wpbonelli force-pushed the fix/concurrent-model-fetch branch from 26c704c to df77f93 Compare September 20, 2026 12:15
@wpbonelli
wpbonelli marked this pull request as ready for review September 20, 2026 12:15
@wpbonelli
wpbonelli merged commit 3802e13 into MODFLOW-ORG:develop Sep 20, 2026
15 checks passed
wpbonelli added a commit to modflowpy/pyphoenix-project that referenced this pull request Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant