title: Python time.sleep() vs event.wait()
body: <p>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</p>
  
  <pre><code>exit = False
  def thread_func(): 
      while not exit:
         action()
         time.sleep(DELAY)
  </code></pre>
  
  <p>or </p>
  
  <pre><code>exit_flag = threading.Event()
  def thread_func(): 
      while not exit_flag.wait(timeout=DELAY):
         action()
  </code></pre>
  
  <p>Is there an advantage to one way over the other?  Does one use less resources, or play nicer with other threads and the GIL?  Which one makes the remaining threads in my app more responsive?</p>
  
  <p>(Assume some external event sets <code>exit</code> or <code>exit_flag</code>, and I am willing to wait the full delay while shutting down)</p>