我在GAE上使用python。以下是示例代码:
try:
response = urlfetch.fetch(url, headers=headers)
except Exception, E:
logging.error("urlfetch failed: %s: %s" %(E, E.__dict__))
对于某些请求,我得到了这个:
urlfetch failed: '_URLFetchResult' object has no attribute 'reason': {}
2011年有一个类似的问题并没有真正解决我的问题:Why am I getting an AttributeError when trying to print out
任何人都知道可能导致此错误的原因是什么?我甚至尝试在请求中添加超时但没有改变任何内容。
答案 0 :(得分:0)
试试这个:
try:
fetch_response = urlfetch.fetch(url, headers=headers)
except:
logging.error("urlfetch failed. Status code: %d" % (fetch_response.status_code))
if fetch_response.status_code == 200:
logging.error("fetch_response.content:")
logging.error(fetch_response.content)