Skip to content

Access to app state in CLI plugins #3384

Discussion options

You must be logged in to vote

Litestar.lifespan() is documented: https://docs.litestar.dev/2/reference/app.html#litestar.app.Litestar.lifespan

The lifespan is only entered by the application in response to the ASGI lifespan startup message from the server, which doesn't happen for cli operations (except litestar run of course).

Your approach looks reasonable to me. Are you encountering any issues?

Another way you can approach it is to have your own lifespan context that is separate from, but called from within the litestar lifespan context. This way you can enter resource contexts separate from the application.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@WulkanHefajstos
Comment options

@peterschutt
Comment options

Answer selected by WulkanHefajstos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants