# SuperFastPython.com
# example of gather for many coroutines in a list
import asyncio

# coroutine used for a task
async def task_coro(value):
    # report a message
    print(f'>task {value} executing')
    # sleep for a moment
    await asyncio.sleep(1)

# coroutine used for the entry point
async def main():
    # report a message
    print('main starting')
    # create a list of coroutines
    coros = [task_coro(i) for i in range(10)]
    # execute and wait for all tasks to be done
    await asyncio.gather(*coros)
    # report a message
    print('main done')

# start the asyncio event loop
asyncio.run(main())