Skip to content

serialise singleton construction in FileLockMeta#581

Open
dxbjavid wants to merge 1 commit into
tox-dev:mainfrom
dxbjavid:singleton-cache-lock
Open

serialise singleton construction in FileLockMeta#581
dxbjavid wants to merge 1 commit into
tox-dev:mainfrom
dxbjavid:singleton-cache-lock

Conversation

@dxbjavid

@dxbjavid dxbjavid commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

FileLockMeta.call reads and writes its singleton cache without a lock, so two threads constructing the same is_singleton=True lock for a fresh path both miss the cache and each build their own instance. That quietly breaks the singleton guarantee callers lean on for reentrant locking across instances, so a later reentrant acquire on what should be the same lock can hit the deadlock check in acquire(), and the concurrent writes to the shared WeakValueDictionary are a race in their own right. ReadWriteLock and SoftReadWriteLock already take their _instances_lock around the get-or-create, so this brings the base metaclass in line.

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.

1 participant