Sobes.tech
Junior — Senior

How is the output order formed when working with asyncio

livecode

Task condition

Analyze why the output of the following code snippet will be exactly 1, 3, 2.

# asyncio / multiprocessing / threading

async def test_1():
    await asyncio.sleep(10000000)
    print('1')
    return data

async def test_2():
    await asyncio.sleep(1)
    print('2')

async def main():
    await test_1()
    print('3')
    await test_2()

asyncio.run(main())
How is the output order formed when working with… - sobes.tech