Description
I'm injecting into lifespan generator. And want to start some background task.
In first case i use default that-depends
flow for injection and task doesn't getting called at all.
But as soon as i resolve dependency myself - then everything works great.
Could you, please, support generator injections?
Code example:
# Doesnt work
@that_depends.inject
@contextlib.asynccontextmanager
async def run_lifespan(
my_dep: ReportsRepository = that_depends.Provide[IOCContainer.my_dep],
) -> typing.AsyncIterator[None]:
async with asyncio.TaskGroup() as task_group:
task_group.create_task(my_dep.my_background_task())
yield
await IOCContainer.tear_down()
# Works correctly
@contextlib.asynccontextmanager
async def run_lifespan() -> typing.AsyncIterator[None]:
my_dep: typing.Final = await IOCContainer.my_dep.async_resolve()
async with asyncio.TaskGroup() as task_group:
task_group.create_task(my_dep.my_background_task())
yield
await IOCContainer.tear_down()