title: How to set a timer & clear a timer?
body: <p>I want to create a timer. When it times out, some actions will be taken. But, I can interrupt this timer and reset it.
  The pseudo code looks like below:</p>
  <pre><code>def timeout():
      print &quot;time out!&quot;
      T.cancel()  # reset timer T
      T = Timer(60, timeout)  
      T.start()
  
  T = Timer(60, timeout)
  
  def interrupt():
      T.cancel()  # reset timer T
      T = Timer(60, timeout)
      T.start()
  
  if __name__ == '__main__':
      T.start()
      while True:
          if something is True:
              # interrupt
  </code></pre>
  <p>The solution I came up with is cancel the timer in function interrupt and then create a new timer. But it seems a timer is canceled and a new timer is created, which is not high performance.
  Any idea?</p>