You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Close path: concurrent close_async finalizes twice, and three untested guarantees #616
This was generated by AI during a third pre-4.0 audit of main at f6e343d.
One bug and three untested guarantees in the close path. Mutation testing changed each of items 2 to 4 in the code and all 989 tests still passed. TDD for each.
Fix: detach the creation order before the first await (or mark items finalized before awaiting), and state in design-decisions whether concurrent close is supported.
Finalizer ownership.resolver_compiler.py:120 appends to target._creation_order. Changing it to container._creation_order passes the suite, yet then an APP singleton first resolved from a REQUEST child is finalized when the child closes and rebuilt afterwards, contradicting docs/providers/lifecycle.md:191. Test: resolve an APP item with a finalizer through a child, close the child, assert the finalizer did not run and the singleton is the same object.
Order of leftover async finalizers. Removing remaining.reverse() in cache.pyclose_sync passes the suite. Test: two async finalizers, sync close, then async close, assert newest first.
No double finalize on the async path. Removing cache_item.finalized = True in cache.pyclose_async passes the suite; test_cached_factory.py:69 covers only sync. Test the clear_cache=False case: close_async, reopen, close_async again.
Small: test_cache.py:114 races threads without the thread_race marker, so the free-threaded stress run skips it. Make just test-race select -m thread_race over the whole suite instead of listing files.
Item 1 is won't-fix: closing one container concurrently is a usage error, now documented as unsupported in design-decisions. Items 2 to 5 shipped in #621.
Activity
test: pin finalizer ownership and close ordering, mark the threaded c…
lesnik512 commentedon Oct 9, 2026
Item 1 is won't-fix: closing one container concurrently is a usage error, now documented as unsupported in design-decisions. Items 2 to 5 shipped in #621.