1_just_some_coros.py 363 Bytes
#!/usr/bin/env python
import asyncio
import random

async def slow_op(n):
    print("slow_op {} started".format(n))
    await asyncio.sleep(random.uniform(0, 2))
    print("slow_op {} complete".format(n))

async def main():
    await asyncio.wait([
        slow_op(i) for i in range(10)
        ])

loop = asyncio.get_event_loop()
loop.run_until_complete(main())