Never wait for the cache lock in __traverse__ - #86
Open
Malkiz223 wants to merge 1 commit into
Open
Conversation
Malkiz223
force-pushed
the
traverse_try_lock
branch
from
August 30, 2026 14:20
db397fa to
8b5a004
Compare
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.
Closes #84. Split out of #85, as requested - the
__traverse__part alone.__traverse__now tries the lock and skips the pass when it is busy: the thread holding the lock may be running Python code (a value's__del__, a key's__eq__,getsizeof), and a collection landing there deadlocked the whole process. Skipping is safe - the cache and its contents just stay reachable until the next pass, and a busy lock means some thread is inside a cache operation and holds a reference to the cache anyway.All four scripts from #84 run to the end with this change. Two regression tests, for all seven cache types, in a child process with a timeout: a dropped value whose
__del__triggers a full collection, and a key whose__eq__triggers one in the middle of a probe. Onmainboth fail with "never returned".