How to fetch a url while building a request in python AppEngine? [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 14:42:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!