I am writing some python wrappers for a c++ library that speaks to a hardware device. The general model of the library is to register a callback routine, then send a command to the hardware and await the callback.
I could simply loop checking a variable which gets set by the callback routine, but that feels stupid, as the program calling the wrappers may some day like to do other stuff while waiting. So I would rather sleep on a semaphore and have the callback do a wakeup on the semaphore so that we can get all multi-threaded in the future.
Is that a thing in Python? I am new to Python, but have experience with multi-threaded c and c++ device drivers. I would like pointers to a clean way to do this in Python 3.
Thanks!