Async/Await/AsyncIO


In [ ]:


In [ ]:
import asyncio

async def say(what, when):
    await asyncio.sleep(when)
    print(what)
    
loop = asyncio.get_event_loop()
loop.create_task(say('Hello', 0.5))
loop.create_task(say('World', 1.0))
loop.run_forever()


Hello
World

In [ ]:


In [ ]:

Useful Reference: