This question already has an answer here:
In order to be able to build a get response when somebody hits /show_data/
url of my service, while I am building it I want to fetch the url /retrieve_data/
from the same service. How can I fire it up in a different thread so I can avoid the DeadLineExceeded errors I am receiving? I am using python 2.7, with threadsafe=true
.
so I have something like this for the /show_data/
handler:
def get(self):
url = '/retrieve_data/'
data_from_my_service = urlfetch.fetch(url)
do_something_with_data(data_from_my_service)
self.redirect('/')
You should use urlfetch async API (no need to involve threads).