Using the discovery.build()
from the google-api-python-client
(version 1.6.2) in my web app is causing timeouts. Running the following piece of code
import httplib2
from apiclient import discovery
http = httplib2.Http()
discovery.build('classroom', 'v1', http=http)
takes about 80 seconds(!) – the timeout on my web server is 30 seconds.
I believe the call the Google API client makes is:
http = httplib2.Http()
response, content = http.request(
'https://www.googleapis.com/discovery/v1/apis/classroom/v1/rest',
'GET',
body=None,
headers={},
)
which also takes about 80 seconds, and retrieves about 141 KiB of data.
Whereas the equivalent curl
:
curl -H 'accept-encoding: gzip, deflate' \
'https://www.googleapis.com/discovery/v1/apis/classroom/v1/rest'
Takes 0.5 seconds.
Why is it taking so long? And what can I do to prevent it – is there a faster way?