title: How to execute a function asynchronously every 60 seconds in Python?
body: <p>I want to execute a function every 60 seconds on Python but I don't want to be blocked meanwhile.</p>
  
  <p>How can I do it asynchronously?</p>
  
  <pre><code>import threading
  import time
  
  def f():
      print("hello world")
      threading.Timer(3, f).start()
  
  if __name__ == '__main__':
      f()    
      time.sleep(20)
  </code></pre>
  
  <p>With this code, the function f is executed every 3 seconds within the 20 seconds time.time.
  At the end it gives an error and I think that it is because the threading.timer has not been canceled.</p>
  
  <p>How can I cancel it?</p>
  
  <p>Thanks in advance!</p>