We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I'm trying to use async resources with list providers but it doesn't seem to work
from typing import List from dependency_injector import containers,providers import asyncio class MyResource: def __init__(self,my_param:str) -> None: self.my_param = my_param async def create_resource(param:str): return MyResource(my_param=param) class Printer: def __init__(self, resources: List[MyResource]) -> None: self.resources = resources def print(self): for r in self.resources: print(r.my_param) class Container(containers.DeclarativeContainer): my_resources = providers.List( providers.Resource(create_resource, "foo"), providers.Resource(create_resource, "bar") ) printer = providers.Factory(Printer, resources = my_resources) async def main(): container = Container() printer = await container.printer() printer.print() if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main())
if I remove the async from the create_resource function and the await infront of container.printer() it works.
async
create_resource
await
container.printer()
Is there anything I missed or is it currently not supported?
The text was updated successfully, but these errors were encountered:
Hey @mxab ,
Yeah, this is a bug. Thanks for reporting this. Working on the fix.
Sorry, something went wrong.
@mxab Fixed in 4.32.1. Thanks again for bringing this up.
4.32.1
Nice! Will try today
rmk135
No branches or pull requests
Hi,
I'm trying to use async resources with list providers but it doesn't seem to work
if I remove the
async
from thecreate_resource
function and theawait
infront ofcontainer.printer()
it works.Is there anything I missed or is it currently not supported?
The text was updated successfully, but these errors were encountered: