I have a question.
I wrote a simple code that mimics http request:
from asyncio import sleep, run
async def get():
print("Started get()")
await sleep(3)
print("Finished get()")
async def async_main():
await get()
await get()
await get()
if __name__ == "__main__":
run(async_main())
I expected that the result should be like:
Started get()
Started get()
Started get()
(No output, just wait 3 seconds)
Finished get()
Finished get()
Finished get()
But the result was:
Started get()
(No output, just wait 3 seconds)
Finished get()
Started get()
(No output, just wait 3 seconds)
Finished get()
Started get()
(No output, just wait 3 seconds)
Finished get()
Why is this happening?
await asyncio.gather(get(), get(), get())