Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'say,': 0.05; 'socket': 0.07; 'subject:Question': 0.07; 'callback': 0.09; 'windows,': 0.09; 'wrapped': 0.09; '24,': 0.16; 'coroutines': 0.16; 'devoid': 0.16; 'email name:<tjreedy': 0.16; 'emit': 0.16; 'reedy': 0.16; 'subject:doc': 0.16; 'wrote:': 0.18; 'module': 0.19; 'later': 0.20; 'meant': 0.20; 'seems': 0.21; 'select': 0.22; 'example': 0.22; 'oriented': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'unix': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'produces': 0.31; 'styles': 0.31; 'run': 0.32; 'another': 0.32; 'style': 0.33; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'functions.': 0.36; 'words,': 0.36; 'should': 0.36; 'two': 0.37; 'easily': 0.37; 'tasks': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'full': 0.61; 'back': 0.62; 'fact,': 0.69; 'jul': 0.74; 'examples.': 0.84; 'streams': 0.84; 'execution,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=woGzAfMTL9sX745y2wm9fc84/zvFDYgh/3cuefBYoYI=; b=vHnTxMSnoRJssTSEUfhzsA9+6S/mEQHmUJmNfCCBygGD/Uc+8fHAFilpKsjfoFRIcO MM3NhAnfy8bb0Isk1Oe9lVa6IPvGP+j0W1iiwbP7iAYU/xbqPifpbhhcW+Bs49MSS3Q/ P1WMcn3XqmSZ+0y78eI85E0tUUAuCy3JJqZfPqSVN92KfVzfq1YOFvmIzYTbj1trDzXO 51FG1cQO4Re8RFc4oqY4yxDjPOFfB2VqX85U7KuTk7a/3xWkrWI2YJJ+cHUOKQvZ3cJX hvdi6JRfxwCk/W0quEWZZxo2IrV74o2Bil0x4v10kUnd7vDKg+0AOV0pxFHFVVCNZk4j Ud0w== MIME-Version: 1.0 X-Received: by 10.67.30.130 with SMTP id ke2mr12181608pad.44.1406220411744; Thu, 24 Jul 2014 09:46:51 -0700 (PDT) In-Reply-To: <87d2cvmd8u.fsf@elektro.pacujo.net> References: <87d2cvmd8u.fsf@elektro.pacujo.net> Date: Thu, 24 Jul 2014 10:46:51 -0600 Subject: Re: Question about asyncio doc example From: Ian Kelly To: Python Content-Type: multipart/alternative; boundary=001a113451221e381c04fef33440 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 63 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406220421 news.xs4all.nl 2935 [2001:888:2000:d::a6]:45236 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75152 --001a113451221e381c04fef33440 Content-Type: text/plain; charset=UTF-8 On Jul 24, 2014 1:26 AM, "Marko Rauhamaa" wrote: > > Terry Reedy : > > > 18.5.3. Tasks and coroutines, seems to be devoid of event wait > > examples. However, there is a 'yield from' network example in 18.5.5 > > Streams using socket functions wrapped with coroutines. These should > > definitely be used instead of sleep. In fact, for cross-platform > > network code meant to run on *nix and Windows, they are better than > > the unix oriented select and poll functions. > > Asyncio has full support for the callback style as well. What I don't > know is how well the two styles mix. Say, you have a module that > produces callbacks and another one that is based on coroutines. The > coroutines can easily emit callbacks but can callbacks call "yield > from"? Callbacks can easily schedule coroutines, but they can't wait on them, because that would require suspending their execution, dropping back to the event loop, and resuming later -- in other words, the callback would need to be a coroutine also. --001a113451221e381c04fef33440 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Jul 24, 2014 1:26 AM, "Marko Rauhamaa" <marko@pacujo.net> wrote:
>
> Terry Reedy <tjreedy@udel.edu>:
>
> > 18.5.3. Tasks and coroutines, seems to be devoid of event wait > > examples. However, there is a 'yield from' network exampl= e in 18.5.5
> > Streams using socket functions wrapped with coroutines. These sho= uld
> > definitely be used instead of sleep. In fact, for cross-platform<= br> > > network code meant to run on *nix and Windows, they are better th= an
> > the unix oriented select and poll functions.
>
> Asyncio has full support for the callback style as well. What I don= 9;t
> know is how well the two styles mix. Say, you have a module that
> produces callbacks and another one that is based on coroutines. The > coroutines can easily emit callbacks but can callbacks call "yiel= d
> from"?

Callbacks can easily schedule coroutines, but they can't= wait on them, because that would require suspending their execution, dropp= ing back to the event loop, and resuming later -- in other words, the callb= ack would need to be a coroutine also.

--001a113451221e381c04fef33440--