问题
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('/')
回答1:
You should use urlfetch async API (no need to involve threads).
来源:https://stackoverflow.com/questions/8916204/how-to-fetch-a-url-while-building-a-request-in-python-appengine