Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106721

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

From "Frank Millman" <frank@chagford.com>
Newsgroups comp.lang.python
Subject Re: (Python 3.5) Asyncio and an attempt to run loop.run_until_complete() from within a running loop
Date 2016-04-09 07:08 +0200
Message-ID <mailman.107.1460178550.2253.python-list@python.org> (permalink)
References <33e44698-2625-47c4-9595-00a8c79f27ad@googlegroups.com> <nea2pa$d0c$1@ger.gmane.org>

Show all headers | View raw


"Alexander Myodov"  wrote in message 
news:33e44698-2625-47c4-9595-00a8c79f27ad@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

(Python 3.5) Asyncio and an attempt to run loop.run_until_complete() from within a running loop Alexander Myodov <amyodov@gmail.com> - 2016-04-08 16:54 -0700
  Re: (Python 3.5) Asyncio and an attempt to run loop.run_until_complete() from within a running loop "Frank Millman" <frank@chagford.com> - 2016-04-09 07:08 +0200
  Re: (Python 3.5) Asyncio and an attempt to run loop.run_until_complete() from within a running loop Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-09 09:14 -0600
  Re: (Python 3.5) Asyncio and an attempt to run loop.run_until_complete() from within a running loop Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-09 09:38 -0600

csiph-web