Question on asyncio
Marko Rauhamaa
marko at pacujo.net
Mon Feb 23 11:30:49 EST 2015
Jonas Wielicki <jonas at wielicki.name>:
> On 23.02.2015 14:27, Marko Rauhamaa wrote:
>> pfranken85 at gmail.com:
>>> 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.
>>
>
> The manual has a word on this [1]. So I would suggest to use
> run_in_executor() instead of trashing and rewriting the whole smbus
> library.
Ok, that's always a fallback. I usually isolate such obnoxious function
calls in a process pool.
But that wouldn't be purely asyncio anymore.
One of the main offenders is the database libraries. They should
definitely provide nonblocking access.
Marko
More information about the Python-list
mailing list