I need to make multiple API requests with different parameters. Currently, doing this sequentially in a for loop. I was wondering if this can be handled asynchronously. In javascript, there is a way to do this with Promise.all. Please advise on how to handle this?
Thanks in advance
Sounds like you want asyncio.gather.
Not sure what you are trying to use this for, but if you are trying to do this to make multiple database requests concurrently within a single request, that's often a bad idea due to transactions, etc. Otherwise, yeah, this should be the way to go.
so is it okay to use asyncio with fastapi? i thought there might be some conflicts. But this is good to go.
I would encourage you to read the docs. This page in particular.
Thanks for the help @dmontagu ! :bowing_man:
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.
Most helpful comment
I would encourage you to read the docs. This page in particular.