title: How do you schedule timed events in Flask?
body: <p>Here's some code:</p>
  
  <pre><code>from flask import Flask, request
  import time, threading
  
  class MyServer(Flask):
      def __init__(self, *args, **kwargs):
          super().__init__(*args, **kwargs)
          self.reset()
  
      def reset(self):
          self.string = "hello"
  
  application = MyServer(__name__)
  
  @application.route("/set")
  def set():
      application.string = request.args["string"]
      threading.Timer(10, application.reset()).start()
      return request.args["string"] + " stored for 10 seconds"
  
  @application.route("/get")
  def get():
      return application.string
  
  if __name__ == "__main__":
      application.debug = True
      application.run()
  </code></pre>
  
  <p>My expectation/goal is that if you visit the endpoint <code>/set?string=foo</code> then for the next 10 seconds the app will return "foo" any time you visit <code>/get</code>, and from then on it will return "hello" until you hit the <code>/set</code> endpoint again.</p>
  
  <p>Instead, if I hit <code>/set?string=foo</code> and then immediately '/get', the app returns "hello" and I see "TypeError: 'NoneType' object is not callable" in the console.  Can anyone help?</p>