Skip to content

Never wait for the cache lock in __traverse__ - #86

Open
Malkiz223 wants to merge 1 commit into
awolverp:mainfrom
Malkiz223:traverse_try_lock
Open

Never wait for the cache lock in __traverse__#86
Malkiz223 wants to merge 1 commit into
awolverp:mainfrom
Malkiz223:traverse_try_lock

Conversation

@Malkiz223

Copy link
Copy Markdown
Contributor

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. On main both fail with "never returned".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A full collection while a cache holds its lock freezes the process

1 participant