Hey all. Let's say I would like to periodically poll for a change in a variable/device/etc. Obviously I would like to use an infinite loop and when need be, break from the loop to end the polling routine. What I don't what to do is peak my processor usage by polling too often.
So my question is, what would be the most efficient way of slow down the execution of code within a loop? So far I've been using time.sleep() to slow down the execution time, but I'm not sure if this is the most efficient/elegant solution. Or perhaps there is there a way to allocate a certain amount of processing ability to a piece of code?