Error when retrieving metadata from the Google Spreadsheet

1 week ago 3
ARTICLE AD BOX

I have two functions:

import gspread def authorization(): json_keyfile = "451208-af95638d0bdf.json" scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive'] credentials = ServiceAccountCredentials.from_json_keyfile_name(json_keyfile, scope) gc = gspread.authorize(credentials) return gc def get_df(gc, table_name, sheet_name, columns_name_index=0): spreadsheet = gc.open(table_name) worksheet = spreadsheet.worksheet(sheet_name) data = worksheet.get_all_values() df = pd.DataFrame(data[columns_name_index+1:], columns=data[columns_name_index]) return df, worksheet

They are called like this:

auth = authorization() df_change_price, change_renta_sheet = get_df(auth, 'Renta', 'Change Renta', columns_name_index=0)

So here's the problem. This piece of script had been running on a server since February 2025. It runs a couple of times a day. Everything worked fine. But a week ago, when reading metadata:

spreadsheet = gc.open(table_name)

I started getting the error: 'Connection broken: IncompleteRead(6429 bytes read, 3811 more expected)'. The number of bytes in the error varies but stays roughly the same.

The same script runs without errors from my local computers. There are other factors that puzzle me. On the same server, there is a second module of the program that accesses the same spreadsheet every few hours. The function calls are exactly the same, the environment is the same, and the spreadsheet opens without issues.

The main script works with many spreadsheets, and all of them open without errors; the problem is only with this specific one. We also tried creating a full copy of the "Renta" spreadsheet, and it still wouldn't open. We made an intermediate copy (grabbed the necessary columns and set dependencies), and that one opens. I have no idea what to do.

Read Entire Article