question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RESOURCE_EXHAUSTED exception from Google; can I just sleep between requests?

See original GitHub issue
  • Check that you’re running the newest version of the library.

  • If you’re providing a stack trace, make sure it doesn’t contain your password.

  • If you’re getting a KeyError or ParseException, please follow the instructions [here]

  • Operating system: MacOS Catalina 10.15.7

  • Python version: 3.9.13

I’m trying to bootstrap gkeepapi for first time against my very-old Keep account. I have 14k+ entries in Keep (checked in Google Takeout). I wrote a simple script with login followed by sync. First run I recall was successful. Second and beyond errors out with RESOURCE_EXHAUSTED. I’m fine with long-running times. Can I just add equivalent of sleep(1) between each request? I looked at the code myself but could not find the equivalent of for loop over requests. If yes, what line of code would I modify in my local gkeepapi?

Trace: File "/usr/local/lib/python3.9/site-packages/gkeepapi/__init__.py", line 241, in send raise exception.APIException(error["code"], error) gkeepapi.exception.APIException: {'code': 429, 'message': "Quota exceeded for quota metric 'Sync requests' and limit 'Sync requests per minute per user' of service 'notes-pa.googleapis.com' for consumer 'project_number:192748556389'.", 'errors': [{'message': "Quota exceeded for quota metric 'Sync requests' and limit 'Sync requests per minute per user' of service 'notes-pa.googleapis.com' for consumer 'project_number:192748556389'.", 'domain': 'global', 'reason': 'rateLimitExceeded'}], 'status': 'RESOURCE_EXHAUSTED', 'details': [{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'RATE_LIMIT_EXCEEDED', 'domain': 'googleapis.com', 'metadata': {'service': 'notes-pa.googleapis.com', 'quota_metric': 'notes-pa.googleapis.com/sync_requests', 'quota_limit_value': '150', 'quota_location': 'global', 'consumer': 'projects/192748556389', 'quota_limit': 'SyncsPerMinutePerProjectPerUser'}}, {'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Request a higher quota limit.', 'url': 'https://cloud.google.com/docs/quota#requesting_higher_quota'}]}]}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jp5282commented, Jul 3, 2022

Oh my gosh - that worked ! Thank you @kiwiz !!!

So for posterity (maybe next person to have this problem), how I/we solved was time.sleep(1) inside while loop like @kiwiz suggested. pip3 uninstall gkeepapi. Then clone gkeepapi from git to local src directoy. Then pip install -e ./ to install modified version of gkeepapi (after inserting sleep call). Then ran the test script and it worked! Thanks @kiwiz !!!

0reactions
jp5282commented, Jul 3, 2022

If anyone needs convincing to use the token/resume and dump/restore patterns for gkeepapi, I did measure execution time in my script. First run, which pulled all from server to dump local copy to disk, took 241.97 seconds. Subsequent runs, which loaded dump from disk and only handled deltas between server and client, took 11.27 seconds. That’s >10x improvement. Thanks again @kiwiz !!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

STT: 429 ResourceExhausted · Issue #5787 - GitHub
I seem to get the 429 ResourceExhausted exception every 12th request for an operation. Having the program sleep for 90 seconds before resuming ......
Read more >
How to put all java ExecutorService's threads in sleep after ...
The problem is that how I can put ALL the threads in sleep after a certain number of requests to Google API? for...
Read more >
Error Handling, Retry, and Timeouts in Google Ads API
The Google Ads API Developer Relations team will be hosting a live webinar covering Error Handling, Retry, and Timeouts** Slide deck link: ...
Read more >
Resource getting exhausted even in the standard access level ...
Hi team,. I am using google Ads REST API's searchStream method to fetch search terms data. I am experiencing an issue saying resource_exhausted ......
Read more >
Handle Rate Exceeded Error | Google Ads API
thread attempting to validate 100 keywords in a single request. While spanning 5 parallel threads * is unlikely to trigger a rate exceeded...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found