picod
picod copied to clipboard
Question: About serial timeout and asyncio serial to prevent blocking
First of all let me express my most sincere appreciation for this development. It is really useful and a time saver!
I have a couple of minor questions regarding the performance or potential blocking issues.
-
I have seen that for the default serial transport, the timeout has been hardcoded to 0, meaning that it returns immediately no matter how many bytes have been received (i guess). But at the same time the serial read function expects a number of bytes (count). Could we have serial reads that do not have all the response bytes? Or despite the timeout=0, is it actually blocking waiting for all the expected bytes to be received?
-
I have spotted several timeouts around the code, specifically for different commands (i2c etc), that might result in blocking the overall execution (as well as for the case of previous question) Could it be feasible to implement an asyncio version of the pyserial transport? Awaitable reads that would yield executin to other asyncio tasks... I was thinking in pyserial asyncio (the natural asyncio implementation of pyserial) or aioserial (https://pypi.org/project/aioserial/) a really simple and straightforward lib.
I have a final question about performance. How performant is for bitbanging pulses etc.
Thank you very much!
I rather lost interest in picod when the API broke and I could not rebuild the daemon. Currently I am concentrating on other activities.
Just about every API call has a reply parameter which can be set to one of the following values.
REPLY_NONE = 0 REPLY_NOW = 1 REPLY_LATER = 2
You could use REPLY_LATER. I'm afraid you would have to look at the code as I don't remember doing any examples.
The idea was reply_callback would be used for async processing.