Running asyncio#


Using asyncio in a notebook is NOT trivial

But it can be done.

If done wrong the error message:

This event loop is already running appears.

For any asyncio functionality to run on Jupyter Notebook you cannot invoke a run_until_complete(), since the loop you will receive from asyncio.get_event_loop() will be active.

So for correct working you must add the task to the current loop:

import asyncio
loop = asyncio.get_event_loop()



Use result() Return the result of the Task. function of asyncio, see