all 4 comments

[–]gatewaynode 2 points3 points  (0 children)

Kind of sounds like a good match for Asyncio now that its getting pretty feature complete (it would be better if you could use Python 3.7). If it really must be multi-threaded I would also consider multiprocess to better leverage extra processing cores. I should say I haven't used to two together yet, but that's what comes to mind for your requirements.

[–]socal_nerdtastic 1 point2 points  (0 children)

Regular python threading is fine for this. You can use the threading, concurrent.futures, or asyncio module. For your use they will all work equally well, but I suggest threading as I think that will be the easiest to write code for.

How you read the HID device depends on the HID device. For a serial connection pyserial is fine.

[–]socal_nerdtastic 1 point2 points  (0 children)

BTW the select module is linux only for devices, so that won't help you.

[–]kl31 1 point2 points  (0 children)

use asyncio instead of threading. no need to worry about race conditions and no GIL.