0

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()
  • Running a background thread won't make the flask app unavailable. Could you check this [post](https://stackoverflow.com/help/how-to-ask) and provide a bit more details? – Balaji Ambresh Jul 20 '20 at 16:28
  • It's unlikely that flask itself is generating the 503 errors. Perhaps a proxy inbetween is. Whatever the case, there's not enough information here to be useful. – Ken Kinder Jul 20 '20 at 19:23
  • I have read that python has a GIL which effectively means that only one thread can access the CPU at once. So does that possibly mean that while the data upload is taking place there is a possibility of the flask main thread getting blocked. – Anant Saurabh Adidamu Jul 27 '20 at 07:28

0 Answers0