-
Notifications
You must be signed in to change notification settings - Fork 1
Description
This issue is for collecting information regarding implementing support for single-threaded asynchronous serial communications via pyserial-ascynio.
As it currently stands the IO delays are relatively small (30-50 ms for a single, successful write/read pair), and there seems to not be a great deal of benefit to doing this. I may implement it anyway, just for the sake of practice, but it's currently lowest-priority.
A combination of multithreading via concurrent.futures.ThreadPoolExecutor with queue.Queue has been sufficient for my own purposes when communicating with multiple pumps while also doing other things (running UI, logging to files, etc.).
If anyone encounters limitations with this approach or is aware of a neat alternative I would love to hear about it!
pySerial itself only has experimental support for use with threading.
Packages
pyserial-asyncioonly has support for OSX, Linux, and BSD
There seems to be experimental support for Windowsaioserialmay be an option
sounds like this just uses multithreading internallyasyncserial-pyonly supports Python 3.6 😞
seems abandoned
Helpful links / resources / examples
- Zach Mitchell's wonderful post on using
pyserial-asynciofantastic tutorial, probably the easiest pattern to implement - Ajit Samudrala on
asyncio,threading, andmultiprocessing - Lei Mao on
asyncio,threading, andmultiprocessing - RealPython article/tutorial on async (general)
- RealPython article/tutorial on
asynciospecifically - Educative blogpost on concurrency/asyncio
- SO thread asyncio vs threads performance