Question on asyncio

Marko Rauhamaa marko at pacujo.net
Mon Feb 23 08:27:47 EST 2015


pfranken85 at gmail.com:

> Hello Marko!
>
> Am Sonntag, 22. Februar 2015 22:21:55 UTC+1 schrieb Marko Rauhamaa:
>> In asyncio, you typically ignore the value returned by yield. While
>> generators use yield to communicate results to the calling program,
>> coroutines use yield only as a "trick" to implement cooperative
>> multitasking and an illusion of multithreading.
>
> Really? I saw several exmaples, where a coroutine returned a value
> which was then picked up from the yield from statement...

Actually, you might have better information in that regard than me. In
my trials, I never used it like that.

> The corresponding call is a call to the python smbus library. It
> includes several sleeps (even though they are only about 50ms).
> Therefore I think it is worthwhile to encapsulate it into a coroutine.

Maybe. Then you'll probably have to rewrite smbus to work asyncio style.
Those sleeps would then be done as "yield from" statements.


Marko



More information about the Python-list mailing list