Repository navigation
馃悰 fix(singleton): reject conflicting async and lease options - #765
Merged
Merged
Conversation
gaborbernat
force-pushed
the
fix-async-singleton-options
branch
from
October 3, 2026 13:42
36abf77 to
0cc652e
Compare
gaborbernat
enabled auto-merge (squash)
October 3, 2026 16:42
The base metaclass forwards a subclass's own options as kwargs and never compared them on reuse, so the async-only hook left SoftFileLease and AsyncSoftFileLease returning the cached lock for a conflicting lease_duration, heartbeat_interval or on_compromise. SoftFileLease now checks those, resolving an omitted heartbeat the way __init__ does, and both overrides chain through super() so AsyncSoftFileLease checks its lease and async options together. The hook takes the metaclass's own _ExtraValue kwargs and returns each mismatch as the two strings the error message prints, so no annotation falls back to object for the mixed loop, executor, callback and float values. The tests drive one table per lock family through all three async lock types and both lease types, check reuse with matching options, and drop the assertions that could not fail on the original bug.
gaborbernat
force-pushed
the
fix-async-singleton-options
branch
from
October 3, 2026 17:04
0cc652e to
f441db1
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.
Reusing a singleton lock ignored every option a subclass adds on top of the base ones.
AsyncFileLockkept the firstloop,executorandrun_in_executorit got, andSoftFileLeasekept the firstlease_duration,heartbeat_intervalandon_compromise:The documented singleton contract says conflicting parameters raise
ValueError. The metaclass sees these options as plain**kwargs, and the subclass alone knows their defaults and how its__init__resolves them, so each class reports its own mismatches from_singleton_extra_mismatchesand merges whatsuper()returns. 馃敀 That letsAsyncSoftFileLeasecheck its lease and async options together. Loops, executors and callbacks compare by identity, ason_acquireddoes, and an omittedheartbeat_intervalresolves to a third of the duration before the comparison.AI assistance: implemented and tested with Codex, then independently reviewed with Codex and Claude Opus.