nithinmurali / pygsheets

Google Sheets Python API v4

Home Page:https://pygsheets.readthedocs.io/en/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Excessive delay and 429 errors when using pygsheets

gh-kg26 opened this issue · comments

I am experiencing an issue with the pygsheets library where it is taking much longer than usual to perform operations and showing a frequent 429 error message. Specifically, when running pygsheets, I am seeing the following message:

Sleeping 1.84 seconds before retry 2 of 3 for request: GET https://sheets.googleapis.com/v4/spreadsheets/1cSLvbo0GIo4T_BapKKd40W8PU1F812nwYpGza1Dp9do?includeGridData=false&fields=%2A&alt=json, after 429

This is happening very frequently, and it did not occurred this frequently before. I am using the following code snippet as the interface:

with open('service_account.json') as source:
    info = json.load(source)
credentials = service_account.Credentials.from_service_account_info(info)
client = pygsheets.authorize(service_account_file=service_account_location)

I have already tried to resolve this issue by looking through the pygsheets documentation and searching online for possible solutions, but I have not been successful so far.

Could you please help me understand what could be causing this issue and suggest any possible solutions? Thank you in advance for your assistance.

I am also attaching a screenshot for reference:

WhatsApp Image 2023-05-08 at 09 32 34

You are probably hitting some of these limits https://developers.google.com/sheets/api/limits . Maybe you have some other scripts running using this API key?

I am working with @gh-kg26 on this project.
Oh interesting, Yes I am using this as my common API Key between a few scripts. I will try using a dedicated API Key and test.

Thank you for your assistance! By temporarily adding a sleep statement, I was able to bypass the issue, as a result. Your support and prompt attention to this matter are greatly appreciated.