Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardPythonawait schedulingSingle-choice MCQ

What does the following snippet print, and what loop-internals fact explains the ordering?

import asyncio async def main(): order = [] async def tagged(n): order.append(n) t1 = asyncio.ensure_future(tagged(1)) asyncio.get_event_loop().call_soon(order.append, 2) t2 = asyncio.ensure_future(tagged(3)) await asyncio.sleep(0) await asyncio.sleep(0) print(order) asyncio.run(main())