Flask Background thread - 503 errors

478 Views Asked by At

I have a flask application with a background thread which is responsible for updating the data every 5 mins. Below is my implementation of it which is causing 503 errors(Service Unavailable) once in a while. What is wrong with this approach? Whats the best way to meet the requirement above?

Implementation:

def run_scheduler()
     has a scheduler which runs the upload function every 5 mins

##I first create a thread with the above function and start running it.
thread = Thread(target=run_schduler)
thread.start()

#And then later I start the flask app
app = Flask(__name__)
app.run()
0

There are 0 best solutions below