在我的Web应用程序中使用google-api-python-client
(版本1.6.2)中的discovery.build()
导致超时。 运行以下代码
import httplib2
from apiclient import discovery
http = httplib2.Http()
discovery.build('classroom', 'v1', http=http)
大约需要80秒(!)–我的Web服务器上的超时时间是30秒。
我相信Google API客户端拨打的电话是:
http = httplib2.Http()
response, content = http.request(
'https://www.googleapis.com/discovery/v1/apis/classroom/v1/rest',
'GET',
body=None,
headers={},
)
这也需要大约80秒,并检索到大约141 KiB的数据。
而等效的curl
:
curl -H 'accept-encoding: gzip, deflate' \
'https://www.googleapis.com/discovery/v1/apis/classroom/v1/rest'
需要0.5秒。
为什么要花这么长时间? 我应该怎么做才能避免这种情况–有没有更快的方法?