0

I was trying to understand and test a simple code

async def func(inp: str) -> str:
    time.sleep(5)
    print(inp)
    return inp

async def run():
    k = await asyncio.gather(*[lol(inp=n) for n in "123"])
    k = [n for n in k]
    print(k)

asyncio.run(run())

OUTPUT

1
2
3
['1', '2', '3']

But I see 5 seconds difference between printing 1, 2 and 3. Aren't all supposed to be working async shouldn't I be getting 1,2 and 3 around the same time?

0 Answers0