issue with sockets
See original GitHub issueEnvironment details
- OS: Alpine (docker image https://hub.docker.com/_/python
python:3.8.0-alpine
) - Python version: 3.8.0
- pip version: ???
google-api-python-client
version: v1.7.11
Steps to reproduce
- Using
Search Console API
, make request for web property, that have millions of data. - Use the code snippet below. Where
site_url
is the URL of web property in Google Search Console that have enough data (100k+ data points).
from googleapiclient.discovery import build
service = build('webmasters', 'v3', credentials=credentials)
query = {'dimensions': ['date', 'page', 'query']}
query['startDate'] = '2019-01-01'
query['endDate'] = '2020-01-01'
query['rowLimit'] = 25000
query['startRow'] = 0
request = service.searchanalytics().query(siteUrl=site_url, body=query)
sometimes_response_sometimes_error = request.execute()
The error result appears irregularly, I was unable to find any additional conditions that makes this fail predictable.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/rq/worker.py", line 886, in perform_job
rv = job.perform()
File "/usr/local/lib/python3.8/site-packages/rq/job.py", line 664, in perform
self._result = self._execute()
File "/usr/local/lib/python3.8/site-packages/rq/job.py", line 670, in _execute
return self.func(*self.args, **self.kwargs)
File "/usr/src/app/searchconsole/data.py", line 90, in load_data_for_property
save_data_batch(property, batch)
File "/usr/src/app/searchconsole/data.py", line 103, in save_data_batch
for data_batch in data_batches:
File "/usr/src/app/searchconsole/google/reports.py", line 103, in generate_lazy
response = request.execute()
File "/usr/local/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/googleapiclient/http.py", line 849, in execute
resp, content = _retry_request(
File "/usr/local/lib/python3.8/site-packages/googleapiclient/http.py", line 184, in _retry_request
raise exception
File "/usr/local/lib/python3.8/site-packages/googleapiclient/http.py", line 165, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/google_auth_httplib2.py", line 197, in request
response, content = self.http.request(
File "/usr/local/lib/python3.8/site-packages/httplib2/__init__.py", line 1982, in request
(response, content) = self._request(
File "/usr/local/lib/python3.8/site-packages/httplib2/__init__.py", line 1650, in _request
(response, content) = self._conn_request(
File "/usr/local/lib/python3.8/site-packages/httplib2/__init__.py", line 1589, in _conn_request
response = conn.getresponse()
File "/usr/local/lib/python3.8/http/client.py", line 1322, in getresponse
response.begin()
File "/usr/local/lib/python3.8/http/client.py", line 303, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.8/http/client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/local/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
Quick fix?
I’m looking for just a quickfix if possible, reading other related issues, but changing httplib2
version doesn’t help.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
8 Signs You Need to Change Your Electric Sockets
Damage can come in a number of forms, such as cracks in the outer casing, loose wall plates that won't tighten up, and...
Read more >What to Do When Your Wall Socket Stops Working
This is a common issue and should always be checked when it appears that a wall socket stops working. If you have multiple...
Read more >A Homeowner's Guide to Troubleshooting Electrical Sockets
Some of the common problems that a new homeowner faces include electrical sockets. You might plug in your phone and then find that...
Read more >How to fix common power socket problems
To check for faulty sockets throughout your house, plug an appliance into each of them to see if it has power. · Before...
Read more >Socket allocation problems cause operations to fail with ...
By default, Windows does not allow users to set up client connections on ports above 5000. After a socket is closed, the socket...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vladignatyev As a quick fix, try increasing the default timeout of the socket. Note, do this right before this line:
service = build('webmasters', 'v3', credentials=credentials)
. Example:socket.setdefaulttimeout(60 * 3)
. Can also try to passnum_retries=int
to.execute()
, not sure if it works in v1.7.11.General socket timeout issue tracked in #709