apiclient.discovery build slow in certain servers
See original GitHub issueThanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you’ve tried the usual “quick fixes”:
- Search the issues already opened: https://github.com/googleapis/google-api-python-client/issues
- Search StackOverflow: https://stackoverflow.com/questions/tagged/google-cloud-platform+python
If you are still having issues, please be sure to include as much information as possible:
Environment details
- OS type and version: Multiple linux distros
- Python version:
2.7
- pip version:
18.1
google-api-python-client
version:1.9.3
Steps to reproduce
- Run apiclient.discovery.build on different servers
- In some servers, the build process takes over 10 minutes just to return the client
Code example
from apiclient.discovery import build
build(service, version, credentials=credentials)
Stack trace
This is a sudden error that started to occur a few weeks ago. I have several servers where I run googleapis’ build method, but I’ve started to notice that in some of them, without any change from my end, the build process started to take a really long time and even timeout in some cases. I have started to use build_from_document instead of build, with a discovery document stored internally (even though the added code just to store the document seems too much for an error that is pretty inexplicable). However, there is another bottleneck in this process, which is the “credentials” part of the build function, which is taking a long time to complete as well and, since this is a google-maintained library which methods are used internally for the downstream code, I have not yet found a work around for it. I have updated httplib2 to the latest version and googleapis as well, but the slowness and timeout continued for the affected servers - it is important to notice that the “slow” servers have the exact same configuration as the “fast” servers - using the same GCP project and client tokens. This is happening regardless of the service (tested with bigquery, drive, analytics (v3 and v4), sheets, and google search console). Besides using build_from_document, I also raised the socket timeout (socket.setdefaulttimeout) before calling the build method to prevent timeout exceptions, but the slowness is a major issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Hi @thassyo-kondado,
We’ve just released version 2.0 of
google-api-python-client
. One of the key features is thatdiscovery.build()
will retrieve discovery documents from the client library itself rather than fetching them over the internet. Please try version 2.0 and let us know if you’re still experiencing an issue. I’m going to close off this issue due to inactivity. If you’re still having trouble, please re-open it with more information.UPDATE I have solved this issue…spent way too long it. googleapis.com hangs on ipv6. The solution forces ipv4.
EOF
UPDATE: WRONG I am beginning to suspect an issue related SSL certificates and it’s handling in python 3.8. EOF
I am facing the same exact issue and I’ve noticed that the connection fails 4 times every-time before the connection is made. At first I thought it was an issue with my code, but while testing with
httplib2
– GET request togoogleapis.com
the same thing happens. I then triedrequests
…same thing. I triedcurl
and it worked. Mind you it’s not a network issue, I tried the same script on various devices on the same connection and same versions of modules all worked just fine. Plus,curl
worked.Would appreciate any feedback…