Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for async injectables #107

Open
roo-oliv opened this issue Aug 16, 2021 · 6 comments
Open

Support for async injectables #107

roo-oliv opened this issue Aug 16, 2021 · 6 comments
Projects
Milestone

Comments

@roo-oliv
Copy link
Owner

roo-oliv commented Aug 16, 2021

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__.

@roo-oliv roo-oliv created this issue from a note in dev board (To do) Aug 16, 2021
@roo-oliv roo-oliv moved this from To do to In progress in dev board Aug 17, 2021
@roo-oliv roo-oliv added this to the 3.5 milestone Aug 17, 2021
@Euraxluo
Copy link

cool

@Euraxluo
Copy link

What do you think of PEP593
typing.Annotated
i think you can add some attr annotated

@roo-oliv
Copy link
Owner Author

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.

@aryaniyaps
Copy link

any updates on planning to support async dependencies?

@roo-oliv
Copy link
Owner Author

roo-oliv commented Dec 13, 2023

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.

@aryaniyaps
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
dev board
In progress
Development

No branches or pull requests

3 participants