title: API call is taking too long to respond. How can I pass the control from this function and come back again later
body: <p>I am creating a chatbot in python flask web server. I have this function that sends query to api and responds back on to the chatbot. </p>
  
  <pre><code>     def generateresponse(command):
         #do something
         text = runapi(uri) 
         return text
  
      def runapi(uri):
         r = requests.get(uri, auth=HTTPBasicAuth(user, password))
         parsed = js.loads(r.text,object_pairs_hook=OrderedDict)
         return parsed
  
     def on_event():
         event = request.get_json()  #receives an event from the chatbot
         #do something
         resp = generateresponse(event)
         apiasyncresp(resp, spaceName)
         return json.jsonify()
  </code></pre>
  
  <p>This runapi method calls a mulesoft api to return the result. However it is taking longer to respond for some of the queries. I want to return a text - "waiting for response" back to the chatbot(if i don't get any response from runapi() in 30 seconds) and keep executing runapi till it returns an output. How can I do so?<br>
  I don't want to stop the response from coming in. I only want that before 30 seconds generateresponse() can return 'waiting' message without pausing the execution of runapi()   </p>