Question on asyncio

Jonas Wielicki jonas at wielicki.name
Mon Feb 23 10:05:16 EST 2015


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.

regards,
jwi

   [1]:
https://docs.python.org/3/library/asyncio-dev.html#handle-blocking-functions-correctly
   [2]:
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.BaseEventLoop.run_in_executor

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20150223/0a149211/attachment.sig>


More information about the Python-list mailing list