Question about asyncio doc example

Ian Kelly ian.g.kelly at gmail.com
Thu Jul 24 12:46:51 EDT 2014


On Jul 24, 2014 1:26 AM, "Marko Rauhamaa" <marko at pacujo.net> wrote:
>
> Terry Reedy <tjreedy at udel.edu>:
>
> > 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140724/e0738148/attachment.html>


More information about the Python-list mailing list