asyncio - run coroutine in the background
marko at pacujo.net
Tue Feb 16 09:17:01 EST 2016
Kevin Conway <kevinjacobconway at gmail.com>:
> If you're handling coroutines there is an asyncio facility for
> "background tasks". The ensure_future  will take a coroutine,
> attach it to a Task, and return a future to you that resolves when the
> coroutine is complete.
Ok, yes, but those "background tasks" monopolize the CPU once they are
scheduled to run.
If your "background task" doesn't need a long time to run, just call the
function in the foreground and be done with it. If it does consume time,
you need to delegate it to a separate process so the other tasks remain
More information about the Python-list