Sobes.tech
Junior — Senior

Determining the order of output in an asynchronous script

livecode

Task condition

Analyze the code below. Indicate the order in which messages will appear in the console and whether there will be a pause between them.

import asyncio

async def foo():
    await asyncio.sleep(10)
    print("foo")

async def bar():
    print("bar")

async def main():
    await foo()
    await bar()

if __name__ == '__main__':
    asyncio.run(main())