Skip to content

docs: say which shutdown hooks run after the root container closes - #53

Merged
lesnik512 merged 1 commit into
mainfrom
docs/shutdown-order
Oct 17, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
docs/shutdown-order

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Adds a "Shutdown order" subsection to the README, after "Sharing a container".

setup_di appends the root container's close to app.on_cleanup, and aiohttp has no public hook that runs after every cleanup handler, so this is a docs fix. The section lists the hooks that run before the close (on_shutdown, cleanup_ctx teardown, on_cleanup added before setup_di) and says that on_cleanup added after setup_di runs after it. For that case it points to manage_lifespan=False with the existing async with container: example.

I ran the repro from the issue (aiohttp 3.14.5, modern-di 4.1.0). The output matches the issue: only on_cleanup added after setup_di gets ContainerClosedError. With manage_lifespan=False and runner.cleanup() inside async with container:, all six cases resolve a live container.

Closes #52

@lesnik512
lesnik512 merged commit 6fd77da into main Oct 17, 2026
12 checks passed
@lesnik512
lesnik512 deleted the docs/shutdown-order branch October 17, 2026 13:33
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.

Document that on_cleanup handlers added after setup_di run after the root closes

1 participant