Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The read operation timed out reading a google spreadsheet #2186

Open
lzamora2798 opened this issue Jul 10, 2023 · 3 comments
Open

The read operation timed out reading a google spreadsheet #2186

lzamora2798 opened this issue Jul 10, 2023 · 3 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@lzamora2798
Copy link

Hi Google team, I am facing an issue when executing this line in Python,

from googleapiclient.discovery import build

service = build('sheets', 'v4', credentials=creds,cache_discovery=False)    
sheet_metadata = service.spreadsheets().get(spreadsheetId=spreadsheet_id).execute()

the final issue on the log is socket.timeout: The read operation timed out
this issue is very rare when executing this issue, as we run this code more than ten times per day. I want to know why this happens and what can I do to resolve this.

we use this version of the module google-api-python-client==2.90.0
and we run this in a lambda on aws

this is the full log of the issue.

Traceback (most recent call last):
File "/var/task/lambdas/createSheet.py", line 66, in _update_spreadsheet
sheet_metadata = service.spreadsheets().get(spreadsheetId=spreadsheet_id).execute()
File "/opt/python/lib/python3.9/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/opt/python/lib/python3.9/site-packages/googleapiclient/http.py", line 923, in execute
resp, content = _retry_request(
File "/opt/python/lib/python3.9/site-packages/googleapiclient/http.py", line 222, in _retry_request
raise exception
File "/opt/python/lib/python3.9/site-packages/googleapiclient/http.py", line 191, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "/opt/python/lib/python3.9/site-packages/google_auth_httplib2.py", line 218, in request
response, content = self.http.request(
File "/opt/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1701, in request
(response, content) = self._request(
File "/opt/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1421, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/opt/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1373, in _conn_request
response = conn.getresponse()
File "/var/lang/lib/python3.9/http/client.py", line 1377, in getresponse
response.begin()
File "/var/lang/lib/python3.9/http/client.py", line 320, in begin
version, status, reason = self._read_status()
File "/var/lang/lib/python3.9/http/client.py", line 281, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/var/lang/lib/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "/var/lang/lib/python3.9/ssl.py", line 1242, in recv_into
return self.read(nbytes, buffer)
File "/var/lang/lib/python3.9/ssl.py", line 1100, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
@GJStathisHF
Copy link

Also having this issue.

Not sure if you found a fix?

@GJStathisHF
Copy link

Hey, don't know if you have a different solve but this issue helped me out.

#709

Also, if you have multiple get calls switching to using batch calls helped me as well.

@GJStathisHF
Copy link

I am still facing problems with this issue however,

I have tried to increase the socket timeout (8 min), tried to force sockets to use IPV4 and switched my get to a batchGet. But I am still getting timeouts.

Is there some limit to reading sheets that are larger then 1MB that is not documented somewhere? It seems to only be an issue when I try to get values from large sheets.

NOTE: the a1 ranges that I try to fetch are not the entire sheet. They are small sections of the sheets that I am pulling in.

@ohmayr ohmayr added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants