injectable
injectable copied to clipboard
Support for async injectables
It's currently not ideal to use this library together with Python's async/await.
We should support asynchronous constructors and factories.
Async constructors are also a bigger problem since one cannot declare an async __init__ method without bending some snakes. This calls for ways to construct and/or setup an injectable other than relying solely on __init__.
cool
What do you think of PEP593 typing.Annotated i think you can add some attr annotated
What do you think of PEP593 typing.Annotated i think you can add some attr annotated
Hi @Euraxluo, thanks for the bringing this to attention! Indeed I'm thinking of how to best support typing.Annotated in this framework. I do believe though that this should be discussed in a separated issue from this one regarding async injectables.
any updates on planning to support async dependencies?
any updates on planning to support async dependencies?
I'll start working on some other issues listed in this project where there is already a clear implementation path but we can talk about this issue to find a good solution so I can work on it right after.
@aryaniyaps it would be great to hear from you if you have any specific suggestions or external examples to enrich this discussion. Or even just your need so we can have a clear set of scenarios we want to cover.
I don't have any specific suggestions in mind, but async support would be nice as the python ecosystem has adapted more and more of the async await syntax
Off the top of my head, the framework could use anyio to resolve the async dependencies by using a iscouroutine check, maybe? This way support is extended to multiple io backends like asyncio and trio!