Is there a way I can get the as_completed results for both result1 and result2
combined?
Expected Output
[0, 0, 1, 1, 2, 2]
Current Output
[0, 1, 2, 0, 1, 2]
Code
import asyncio
async def sleep(i):
await asyncio.sleep(i)
return i
async def main():
result1 = [sleep(i) for i in [2, 1, 0]]
result2 = [sleep(i) for i in [2, 1, 0]]
result1Gathered = asyncio.as_completed(result1)
result2Gathered = asyncio.as_completed(result2)
result = await asyncio.gather(*result1Gathered, *result2Gathered)
print(result)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())