Hello! I am currently running a Flask app, which accept a POST call and then does some processing and other requests. The problem is that the service that sends the POST call requires a 200 response within 5 seconds, otherwise it starts send the call again and again. So what I am trying to achieve is for Flask app to send the response first, before the other processes. Currently I put multiprocessing in, but it still seems like it waits until everything is finished processing before sending a response:
@app.route('/', methods=['POST'])
def send_response():
data = request.json
p = Process(target=handle_webhook, args=(data,))
p.start()
response = Response(status=200)
print("sending response")
return response
def handle_webhook(sh_data):
some processes and requests
I know PA doesn't allow threading. Would be grateful for any help!