Dependency injection for background task #4178
Replies: 1 comment
DI only works on route handlers |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I cannot find a way to get dependency injection to work for background tasks.
What I would like to achieve:
`async def bool_fn() -> bool: ...
async def on_startup(app: Litestar, my_dep: bool) -> None:
pass
Litestar(
on_startup=[on_startup],
dependencies={
"my_dep": Provide(bool_fn)
},
),`
Is that possible in any way or does DI only work on request handlers?
All reactions