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


Groups > comp.lang.python > #94712

Re: Send data to asyncio coroutine

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.079
X-Spam-Evidence '*H*': 0.84; '*S*': 0.00; '"""': 0.05; 'generators': 0.09; 'here?': 0.09; 'methods,': 0.09; 'python': 0.10; 'async': 0.16; 'coroutines': 0.16; 'foo()': 0.16; 'foo():': 0.16; 'wrote:': 0.16; 'basically': 0.18; 'implementing': 0.18; '2015': 0.20; 'developer': 0.20; 'for?': 0.23; 'this:': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'equivalent': 0.27; 'message- id:@mail.gmail.com': 0.27; 'yield': 0.27; 'function': 0.28; 'blocking': 0.29; 'invoke': 0.29; 'javier': 0.29; "i'm": 0.30; "can't": 0.32; 'knows': 0.32; 'non': 0.32; 'maybe': 0.33; 'foo': 0.33; 'tue,': 0.34; 'this?': 0.34; 'received:google.com': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'doing': 0.38; 'stuff': 0.38; 'data': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'waiting': 0.60; 'no.': 0.62; 'yes': 0.62; 'skip:n 10': 0.62; 'more': 0.63; 'everybody': 0.67; 'capabilities': 0.72; 'jul': 0.72; 'await': 0.76; 'lack': 0.76; '"yield': 0.84; 'flexible,': 0.84; 'from"': 0.84; 'subject:Send': 0.84; 'to:name:python': 0.84; 'from.': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=JGpW4gDxAlVJ83iALRU+QrJ2bZnwRLk594Mkstj980c=; b=o0H7jMr2/VXUSEBYFB3pVw/d4xoLtBubbwn3VFnHvoXYl5QERdk1Zb1dTHUcjprWG9 LXPaG0s0AEwQjVHWPoGp+PN6dwc7huFD/Z1OWx1jl5GItimRz7HaS+Xf+DGWslCLwhKO soiH/L0fyePVMqwdPBvRbT7Q+wbDwEdepyjcv0N7uEpkcW5hfH5IeDhzQhtvenuvvndg ivWePnKf5fJnkXfTkf10qNzA6Ijb7EuSQdzuMt8jW0L9dc5Xh50bzdaGHbnUcQPLEETY liCe+lL65kV6WWxCKGYV3ezInptoQxg2vVLJu5pawlvI7avUoJW4ca+crQl+1RVSkdJn v1Ng==
X-Received by 10.107.41.11 with SMTP id p11mr54660812iop.148.1438125666921; Tue, 28 Jul 2015 16:21:06 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <bee1c962-5860-40de-b714-38791a930789@googlegroups.com>
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 Tue, 28 Jul 2015 15:20:27 -0800
Subject Re: Send data to asyncio coroutine
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1054.1438131695.3674.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1438131695 news.xs4all.nl 2836 [2001:888:2000:d::a6]:40015
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:94712

Show key headers only | 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