Search code examples
pythonfunctionflaskreturnslack

Python: returning a value and calling a separate function at the same time?


I need to return an http 200 OK status code at the end of a function while also calling a separate function to execute. If I return them at the same time, only the function executes and the http 200 ok never goes through. If one is placed before the other, the second will never execute.

This is my current return statement:

return (make_response("", 200), listener())

Where make_response() sends the http 200 OK status through my Flask app, and the listener starts a loop to listen for a keyword in Slack.


Solution

  • Since the keyword return needs the results from the function listener to return, it will only execute when the listener function has finished

    Otherwise what would the return command return? One of the thinks you asked it to return is the results of the listener function....