(Python 3.5) Asyncio and an attempt to run loop.run_until_complete() from within a running loop

Frank Millman frank at chagford.com
Sat Apr 9 01:08:52 EDT 2016


"Alexander Myodov" wrote in message 
news:33e44698-2625-47c4-9595-00a8c79f27ad at googlegroups.com...
> Hello.

> TLDR: how can I use something like loop.run_until_complete(coro), to 
> execute a coroutine synchronously, while the loop is already running?

I am no expert, but does this help?
"If you're handling coroutines there is an asyncio facility for "background 
tasks". asyncio.ensure_future() will take a coroutine, attach it to a Task, 
and return a future to you that resolves when the coroutine is complete."
This advice was given to me a while back when I wanted to run a background 
task. It works perfectly for me.
Frank Millman


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /