svcs icon indicating copy to clipboard operation
svcs copied to clipboard

Async factories don't trigger context manager

Open tuukkamustonen opened this issue 6 months ago • 2 comments

async def factory(c: Container):
    some_stuff = await c.aget(SomeOtherType)  # async factory because we want to do this
    return SomeType(some_stuff)

registry.register_factory(SomeType, factory)

Let's say SomeType is also context manager. The code won't enter/exit the context manager because that only happens if the factory is not awaitable.

tuukkamustonen avatar Jul 29 '24 14:07 tuukkamustonen