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


Groups > comp.lang.python > #94712

Re: Send data to asyncio coroutine

References <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> <mailman.815.1437486150.3674.python-list@python.org> <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> <bee1c962-5860-40de-b714-38791a930789@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2015-07-28 15:20 -0800
Subject Re: Send data to asyncio coroutine
Newsgroups comp.lang.python
Message-ID <mailman.1054.1438131695.3674.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jul 28, 2015 at 2:41 PM, Javier <jcarmena@gmail.com> wrote:
> I think that force the developer to 'yield from' all function calls to keep async capabilities is a big mistake, it should be more flexible, like this:
>
> import asyncio
>
> @asyncio.coroutine
> fun non_blocking_io():
>     """ Everybody knows I'm doing non blocking IO """
>     ...
>
> fun foo():
>     """ I invoke functions that do IO stuff """
>     data = yield from non_blocking_io()
>     yield from store_data_db(data)
>     ...
>
> fun bar():
>     """ I don't know what foo implementation does """
>     foo()
>
> asyncio.async(bar())

Do you have a proposal for implementing this? What does "yield from"
actually do here? How does the event loop know that foo is waiting for
something and what it is waiting for?

> Does python 3.5 await/async solve this?

Yes and no. await is basically equivalent to yield from with extra
validation, so you still can't use them like what you have above. But
native coroutines are also clearly not generators as they lack
__next__ and __iter__ methods, so maybe there will be less temptation
to try to use them without using await / yield from.

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


Thread

Send data to asyncio coroutine jcarmena@gmail.com - 2015-07-21 04:31 -0700
  Re: Send data to asyncio coroutine Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-21 07:35 -0600
    Re: Send data to asyncio coroutine Javier <jcarmena@gmail.com> - 2015-07-28 14:17 -0700
      Re: Send data to asyncio coroutine Javier <jcarmena@gmail.com> - 2015-07-28 15:41 -0700
        Re: Send data to asyncio coroutine Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-28 15:20 -0800
      Re: Send data to asyncio coroutine Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-28 15:06 -0800
        Re: Send data to asyncio coroutine Rustom Mody <rustompmody@gmail.com> - 2015-07-28 19:52 -0700
        Re: Send data to asyncio coroutine Javier <jcarmena@gmail.com> - 2015-07-29 07:24 -0700
  Re: Send data to asyncio coroutine Javier <jcarmena@gmail.com> - 2015-08-01 09:07 -0700
    Re: Send data to asyncio coroutine Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-01 17:41 +0100
      Re: Send data to asyncio coroutine Javier <jcarmena@gmail.com> - 2015-08-01 11:22 -0700
        Re: Send data to asyncio coroutine Marko Rauhamaa <marko@pacujo.net> - 2015-08-01 21:38 +0300
          Re: Send data to asyncio coroutine Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-01 19:45 +0100
            Re: Send data to asyncio coroutine Javier <jcarmena@gmail.com> - 2015-08-01 12:07 -0700
              Re: Send data to asyncio coroutine Marko Rauhamaa <marko@pacujo.net> - 2015-08-01 22:14 +0300
                Re: Send data to asyncio coroutine Javier <jcarmena@gmail.com> - 2015-08-01 17:50 -0700
              Re: Send data to asyncio coroutine Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-01 20:33 +0100
              Re: Send data to asyncio coroutine Chris Angelico <rosuav@gmail.com> - 2015-08-02 09:28 +1000
            Re: Send data to asyncio coroutine Marko Rauhamaa <marko@pacujo.net> - 2015-08-01 22:09 +0300
              Re: Send data to asyncio coroutine Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-01 20:29 +0100
    Re: Send data to asyncio coroutine Marko Rauhamaa <marko@pacujo.net> - 2015-08-01 20:18 +0300
      Re: Send data to asyncio coroutine Javier <jcarmena@gmail.com> - 2015-08-01 10:50 -0700
        Re: Send data to asyncio coroutine Marko Rauhamaa <marko@pacujo.net> - 2015-08-01 21:33 +0300

csiph-web