title: Cancellable threading.Timer in Python
body: <p>I am trying to write a method that counts down to a given time and unless a restart command is given, it will execute the task. But I don't think Python <code>threading.Timer</code> class allows for timer to be cancelable.</p>
  
  <pre><code>import threading
  
  def countdown(action):
      def printText():
          print 'hello!'
  
      t = threading.Timer(5.0, printText)
      if (action == 'reset'):
          t.cancel()
  
      t.start()
  </code></pre>
  
  <p>I know the above code is wrong somehow. Would appreciate some kind guidance over here.</p>