feat(_internal): Add typed, asyncio-friendly file locking module#501
Open
feat(_internal): Add typed, asyncio-friendly file locking module#501
Conversation
tony
added a commit
that referenced
this pull request
Dec 30, 2025
…module why: Enable safe concurrent access to shared resources across multiple processes, particularly for pytest-xdist parallel test execution. what: - Add FileLock class with context manager support - Add atomic_init() for one-time initialization with locking - Support both sync and async usage patterns - Use fcntl for Unix file locking
what: - Add FileLock context manager tests - Add atomic_init race condition tests - Add timeout and error handling tests - Add multi-process locking tests
what: - Add docs/internals/file_lock.md with API reference - Add file_lock to internals toctree
tony
added a commit
that referenced
this pull request
Dec 30, 2025
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #501 +/- ##
==========================================
+ Coverage 53.22% 55.56% +2.34%
==========================================
Files 38 40 +2
Lines 5676 6117 +441
Branches 1063 1095 +32
==========================================
+ Hits 3021 3399 +378
- Misses 2144 2202 +58
- Partials 511 516 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2 tasks
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.
Summary
FileLockclass for cross-platform file locking with context manager supportatomic_initfunction for race-free initialization (useful with pytest-xdist)Test plan