title: Least painful way to run a Python delay loop
body: <p>I've got an event-driven chatbot and I'm trying to implement spam protection.  I want to silence a user who is behaving badly for a period of time, without blocking the rest of the application.</p>
  
  <p>Here's what doesn't work:</p>
  
  <pre><code>if user_behaving_badly():
    ban( user )
    time.sleep( penalty_duration )  # Bad! Blocks the entire application!
    unban( user )
  </code></pre>
  
  <p>Ideally, if user_behaving_badly() is true, I want to start a new thread which does nothing but ban the user, then sleep for a while, unban the user, and then the thread disappears.</p>
  
  <p><a href="http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/3/" rel="nofollow">According to this</a> I can accomplish my goal using the following:</p>
  
  <pre><code>if user_behaving_badly():
    thread.start_new_thread( banSleepUnban, ( user, penalty ) )
  </code></pre>
  
  <p>"Simple" is usually an indicator of "good", and this is pretty simple, but everything I've heard about threads has said that they can bite you in unexpected ways.  My question is: <strong>Is there a better way than this to run a simple delay loop without blocking the rest of the application?</strong></p>