Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Prevent Python for loop from breaking if Google API limit reached

I currently have a python script that has a for loop that is triggered by an entry into my MongoDb databased. The script does some calculations before printing the results to a Google Sheet. The loop could be triggered every hour or in some cases, several times per second. This issue I’m facing is that the Google API has usage limits that are occasionally being exceeded and thus breaking the loop.

What I want to do, is use some code that will attempt to print the results to Google Sheets using Google’s API but if there’s a usage limit, sleep for 2 minutes before resuming, instead of breaking the loop because of the error.

Can anyone recommend where to start?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I would use try to save to sheet and except to sleep 2 mins then save to sheet

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading