title: How to schedule a periodic task in Python?
body: <p>How can I schedule a periodic task in python without blocking?</p>
  <p>Here is a simple situation. Assume this ticket variable becomes invalid after 2 hours. So I need to fetch it from a serve.</p>
  <pre><code>ticket = 1 # It expires every 2 hours
  
  def process_using_ticket(): # This function is called using a get request from flask server 
      print('hello', ticket) 
  </code></pre>
  <p>How can I reset to 1 every two hours without blocking?</p>
  <p>One way could be to start a thread and sleep for 2 hours and then reset the variable but I am wondering if there are better alternatives.</p>
  <p><strong>Note: Everything runs in a docker.</strong></p>