I want to perform an action at a regular interval in my multi-threaded Python application. I have seen two different ways of doing it
exit = False
def thread
It is interesting to note that the event.wait() method can be invoked on its own:
from threading import Event # Needed for the wait() method
from time import sleep
print("\n Live long and prosper!")
sleep(1) # Conventional sleep() Method.
print("\n Just let that soak in..")
Event().wait(3.0) # wait() Method, useable sans thread.
print("\n Make it So! = )\n")
So why -not- use wait() as an alternative to sleep() outside of multi-threading? In a word, Zen. (Of course.) Clarity of code is an important thing.