This Python 3.10 code
import asyncio
import time
async def say_after(delay, what):
await asyncio.sleep(delay)
print(what)
async def main():
t1 = asyncio.create_task(say_after(1, 'task 1'))
t2 = asyncio.create_task(say_after(2, 'task 2'))
print(f'Start at {time.strftime("%X")}')
await t2
print(f'End at {time.strftime("%X")}')
asyncio.run(main(), debug=True)
outputs this:
Start at 03:32:50
task 1
task 2
End at 03:32:52
I didn't await t1 but it still runs.
Code is taken from here and modified.