Repository navigation
fix: lock that does not lock, and undeclared typing_extensions - #15
Merged
tlambert03 merged 2 commits intoSep 30, 2026
Merged
Conversation
`import witty` failed in an environment that does not happen to have typing_extensions (it is imported for `deprecated`, which is in `warnings` as of python 3.13). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The lock file was in a temporary directory, which is a different one for each process: nothing was locked. Two processes compiling the same module for the first time would both write it, and fail (or load a module that is there in parts). The lock file is now next to the module, and the module is built next to its destination, to then be moved there at once. On Windows, the lock was on as many bytes as there are in the lock file, which is none. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15 +/- ##
==========================================
- Coverage 92.94% 92.69% -0.25%
==========================================
Files 2 2
Lines 170 178 +8
==========================================
+ Hits 158 165 +7
- Misses 12 13 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Two problems found while working on funkey/waterz#25.
The lock did not lock anything
The lock file was created in the temporary directory that holds the source, which is a different one for every call. No two processes ever locked the same file, so processes compiling the same module for the first time all compiled it, into the same destination.
With four processes doing that (the new
test_concurrent_compilation), onmain:Now:
<module>.lockin the output directory), so that one process compiles and the others wait and load the resultos.replace, so that it is never there in parts (for example if the build is interrupted)On Windows, the lock was on
os.path.getsize(lock_file)bytes, which is 0 for a file that was just opened for writing. It is one byte now, and it retries, sinceLK_LOCKgives up after ten seconds, which is less than a compilation can take. I could not run this on Windows locally; the new test runs there in CI.Not addressed:
nb_combined.ofor nanobind modules is built into the cache directory under the lock of the module that needs it, so two different nanobind modules compiled concurrently for the first time can still both build it.typing_extensionsis imported, and not a dependencyIt is only needed for
deprecated, which iswarnings.deprecatedas of python 3.13. It is a dependency for older versions now, and not imported on newer ones.Testing
test_concurrent_compilationfails onmainand passes here (macOS, python 3.9, 3.12, 3.13, 3.14)typing_extensions) and 3.14 (does not)🤖 Generated with Claude Code