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


Groups > comp.lang.python > #106739

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

From Ian Kelly <ian.g.kelly@gmail.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 09:38 -0600
Message-ID <mailman.124.1460216327.2253.python-list@python.org> (permalink)
References <33e44698-2625-47c4-9595-00a8c79f27ad@googlegroups.com> <CALwzid=nr4FTtt-iQJEG8CwnpbXR-=QctCous0fi0YdC1BP_cA@mail.gmail.com> <CALwzidkHOTXpKN66n9o-2Y0qaCVZAz=CbX_Vr1C6f12QoXUMnA@mail.gmail.com>

Show all headers | View raw


On Sat, Apr 9, 2016 at 9:14 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Fri, Apr 8, 2016 at 5:54 PM, Alexander Myodov <amyodov@gmail.com> wrote:
> This does mean that the pattern for calling aio_map from outside the
> event loop is different from calling it inside the event loop. Your
> main_loop coroutine becomes (note the addition of the "await"):
>
> async def main_loop(loop):
>     results = list(await aio_map(fetch_aio, range(5)))
>     assert(results == [{'aio_arg': '0'}, {'aio_arg': '1'}, {'aio_arg':
> '2'}, {'aio_arg': '3'}, {'aio_arg': '4'}]), results
>     print('Assert ok!')

As a final afterthought, note that the result of asyncio.gather is
already a list, so wrapping it in a list() call here is redundant.

Back to comp.lang.python | Previous | NextPrevious 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