Flask - Response before processing

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,))


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!

i would suggest receiving the post, and putting the post params onto a queue (eg: into a db row, write a file onto disk etc). and later on have an always on task draw from that queue to process the post (eg: every 5min it checks to see if new files are available, and then processes them). ie. don't do the processing on the webapp end.

Thanks for the suggestion! I'll try it.