I am supposed to give reply in 3 seconds.
My handler talks with 3rd party server, which could reply in 3 seconds or could not.
I think about the following code -
class MainReply(webapp2.RequestHandler):
def get(self):
# do something
# start task to talk with 3rd server
for i in range(300): # wait 3 seconds
# check task status
# if finished, then break
time.sleep(0.01)
# if not finished, inform user
Is it correct approach? Or is there better solution?
Upd. I am working on Voice Assistant bot (something similar to Google Assistant), where bot must reply within 3 seconds. And bot can not initiate answer itself, i.e. I can not give another answer, once request is completed. And since this is voice assistant, I can not give link. I was thinking about the following approach - if I can give a normal answer in 3 seconds, then give it. If not - ask user to ask again with simple word like "Status".