URLFetch不支持精细的超时设置,恢复为总的或默认的URLFetch超时

问题描述 投票:0回答:1

我们有一个在python2.7标准google应用引擎上的应用(app-a)。我们基于示例here,尝试通过编程身份验证来使用服务帐户访问另一个应用程序(app-b)。 App-b在python3.7标准的Google App Engine上。

[进行iap身份验证的呼叫时,我们在App-A的日志中收到以下错误。

resp = requests.request(
    method, url,
    headers={'Authorization': 'Bearer {}'.format(
        google_open_id_connect_token)}, **kwargs)

AppEnginePlatformWarning: urllib3 is using URLFetch on Google App Engine sandbox instead of sockets. To use sockets directly instead of URLFetch see https://urllib3.readthedocs.io/en/latest/reference/urllib3.contrib.html.

AppEnginePlatformWarning: URLFetch does not support granular timeout settings, reverting to total or default URLFetch timeout.

[requests.request错误与

 Exception("Bad response from application: 500 / {'content-type': 'text/html', 'x-cloud-trace-context':

在App-B中,我们试图接收从App-a发送的数据。

json.loads(request.data)

我们在应用程序b的日志中收到以下错误。

in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/opt/python3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

这使我相信app-a能够成功调用app-b。但是由于某种原因,它无法传递数据。请帮助。

python-3.x python-2.7 google-app-engine urllib3 urlfetch
1个回答
0
投票

AppEnginePlatformWarningrequests library使用的urllib3引发。

Urllib3提供了默认情况下使用URL Fetch API的池管理器。有时候,尽管不是用例的最佳选择。一种解决方案是改用套接字。为此,您必须配置app.yaml并包括以下字段:

env_variables:
    GAE_USE_SOCKETS_HTTPLIB : 'true'

您也可能在Google documentation中找到了相关文档。

让我知道这是否有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.