Slide 72
Slide 72 text
async def i_take_a_while():
print('slow func start')
await asyncio.sleep(3)
print('slow func done')
async def i_run_fast():
print('fast func start')
await asyncio.sleep(1)
print('fast func done')
async def run_me():
await asyncio.gather(
i_run_fast(),
i_take_a_while()
)
loop = asyncio.get_event_loop()
loop.run_until_complete(run_me())
loop.close()
Event loop i_take_a_while
i_run_fast
slow func
start
fast func
start
1 sec after start
fast func
done
3 sec after start
slow func
done