I was going through the Python documentation for asyncio
and I'm wondering why most examples use loop.run_until_complete()
as opposed to Asyncio.ensure_future()
.
For example: https://docs.python.org/dev/library/asyncio-task.html
It seems ensure_future
would be a much better way to demonstrate the advantages of non-blocking functions. run_until_complete
on the other hand, blocks the loop like synchronous functions do.
This makes me feel like I should be using run_until_complete
instead of a combination of ensure_future
with loop.run_forever()
to run multiple co-routines concurrently.