Skip to content

Forget an instance even when its finaliser raises - #327

Merged
antonrh merged 1 commit into
mainfrom
fix-release-drops-instance
Aug 31, 2026
Merged

antonrh merged 1 commit into
mainfrom
fix-release-drops-instance

Conversation

@antonrh

@antonrh antonrh commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

A regression from the release fix earlier this week, found by a second review
pass over it.

release() ran the finaliser before dropping the instance, so a finaliser
that raised left the instance cached with its resource already closed. The
next resolution handed that closed instance out:

release raised: finaliser blew up
still cached: True
events after resolving again: ['open']     # no second open

The instance is dropped first now, and the same run reads:

still cached: False
events after resolving again: ['open', 'open']

The ordering also aborted reset() halfway, leaving later singletons neither
closed nor reset, with nothing to say which half had run. reset() now
releases them all and raises the first failure afterwards:

events: ['a open','b open','c open','a close','b close','c close']
still cached: none

Before this week's change reset() used pop, which cannot raise, so it
always finished. This restores that guarantee without giving up the closing.

@codspeed

codspeed Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 17 untouched benchmarks


Comparing fix-release-drops-instance (60bf1d0) with main (cd2a974)

Open in CodSpeed

@antonrh
antonrh force-pushed the fix-release-drops-instance branch from 617c884 to 60bf1d0 Compare August 30, 2026 12:47
@antonrh
antonrh merged commit f481f80 into main Aug 31, 2026
10 checks passed
@antonrh
antonrh deleted the fix-release-drops-instance branch August 31, 2026 07:16
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