I have a flask application which listens for some job to do. The process is quite long (let us say 1 minute) and I would like not allow to process two requests at the same time.
I will be great if once I receive a request, I could close the port flask is listening to and open again when finish. Alternatively I could setup a semaphore but I am not sure about how flask is running concurrently.
Any advice?
from flask import Flask, request
app = Flask(__name__)
@app.route("/",methods=['GET'])
def say_hi():
return "get not allowed"
@app.route("/",methods=['POST'])
def main_process():
# heavy process here to run alone
return "Done"
if __name__ == "__main__":
app.run(debug=True,host='0.0.0.0')