【问题标题】:HTTPException: Deadline exceeded while waiting for HTTP on Google AppEngineHTTPException:在 Google AppEngine 上等待 HTTP 时超过了最后期限
【发布时间】:2013-04-04 06:10:08
【问题描述】:

在 Python AppEngine 上出现以下错误:

HTTPException: 等待来自 URL: https://www.googleapis.com/books/v1/users/115429583296661000087/bookshelves/1001/volumes?maxResults=12&startIndex=0 的 HTTP 响应时超出了期限

URL 是 .json 格式,我通过我的应用程序中的以下代码获取它:

request = urllib2.Request(bookShelfUrl, None, {'Content-Type': 'application/json'})
bookShelfJsonRaw = urllib2.urlopen(request)  
bookShelfJsonObject = json.load(bookShelfJsonRaw) 

在 localhost 中测试时工作正常,只会在生产中出错。直到今天它神秘地开始返回该错误时,它在生产中也运行良好。

有什么想法吗?

【问题讨论】:

    标签: google-app-engine python-2.7


    【解决方案1】:

    我不知道是 google 解决了这个问题,还是在我修改代码并指定 timout 参数而不是 http 实例化的 deafults 后它立即开始工作:

    httplib2.Http(timeout=15)
    

    【讨论】:

      【解决方案2】:

      Google Books gData API 超时,因为我没有传递国家/地区代码。无论出于何种原因,在没有国家/地区的本地测试服务器上它都可以正常工作,但是每当我将其推送到生产环境时,它都会超时。添加 country=US 后,json 提要运行良好。

      bookShelfUrl = 'https://www.googleapis.com/books/v1/users/' + \
      bookShelfId + \
      '/bookshelves/1001/volumes?' + \
      'maxResults=' + str(maxResults) + \
      '&startIndex=' + str(startIndex) + \
      '&country=US'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-09-28
        • 1970-01-01
        • 2013-01-19
        • 1970-01-01
        • 2022-01-15
        • 2021-02-13
        • 2015-10-13
        • 2013-10-23
        相关资源
        最近更新 更多