title: Python repeat function in flask until desired result with 40 second delay
body: <p>I have code to close a gate with Flask on Raspberry Pi.  The gate moves slow and when I trigger the motor, it may open, close or stop depending on where it is at in the controller cycle.</p>
  
  <p>I want the close() function to check if close limit switch is tripped and if not then trigger motor.  After 40 second delay I want to repeat this until the close limit switch is tripped.</p>
  
  <p>Here is my close function</p>
  
  <pre><code>def Close():
      # Check Close Sensor
      if CloseCheck() == False:
      return 'Gate is Closed'
  
      trigger()
      sleep(40)
      Close()
      return null
  </code></pre>
  
  <p>Flask does not seem to be waiting for the sleep request.  Is this normal behavior? How can I re-run Close function every 40 sec until Close Sensor is triggered? </p>