You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not that familiar with this new AsyncSession object, but it looks to me like the async/await example doesn't actually perform those GET requests concurrently as you are awaiting for each one to return one by one. Should that example be this instead?
async def _main():
for future in asyncio.as_completed([session.get('http://httpbin.org/get') for _ in range(100)]):
print(await future)
The text was updated successfully, but these errors were encountered:
The session.request() method returns twisted Deferred objects; these can't really be treated as futures. You'd want to put all the deferreds into a DeferredList, I think. I'm not that versed in Twisted and their asyncio integration.
you can just append the deferreds to a standard list and then await them all in a for loop. the for loop ends at roughly the same time as the slowest task, and is only slowed down by overhead from Python.
I'm not that familiar with this new AsyncSession object, but it looks to me like the async/await example doesn't actually perform those GET requests concurrently as you are awaiting for each one to return one by one. Should that example be this instead?
The text was updated successfully, but these errors were encountered: