I have a program running that basically looks at a Google Calendar that ties scheduled events to when relays should be turned on/off. The Google Calendar is reached using a Google Apps Script that has done the OAUTH authentication to the calendar already, thus sending back an unauthenticated JSON block of calendar events for the next two weeks.
Full source is public at https://github.com/watermark-woods/GateController
The program checks for calendar updates once a minute. Everything works fine at first.
The call to the calendar is wrapped in a try/except block.
Code: Select all
try:
response = http_req.get(calendar_url, timeout=15)
except BaseException as err:
print("Error getting calendar data")
print(err)
return cached_data
except:
print("Error getting calendar data: Unknown error")
return cached_data
Then 12 hours later, it fails and won't recover. My program keeps a cached copy of the last known good calendar data so it can continue to run, but will not receive new calendar updates and eventually the cache will be too far out of date.-------------- CALENDAR --------------
-------------- CALENDAR --------------
current time 2023-03-13 20:22:59
-------------- CALENDAR --------------
current time 2023-03-13 20:23:59
-------------- CALENDAR --------------
current time 2023-03-13 20:24:59
Error getting calendar data
-------------- CALENDAR --------------
current time 2023-03-13 20:25:59
Error getting calendar data
-------------- CALENDAR --------------
current time 2023-03-13 20:26:59
-------------- CALENDAR --------------
current time 2023-03-13 20:27:59
current time 2023-03-13 18:23:38 <-- when the program started
current time 2023-03-14 06:44:47 <-- point when all subsequent calendar fetches fail
If I reset the board, world is good. I can in parallel open a browser and hit the same calendar URL and receive data successfully even when the board fails on its attempt, so it isn't a quota issue that I can tell. I've researched on Google and haven't found anything to indicate I'm exceeding calls.
I'm about to the point of rewriting this in C++ for better stability, but thought I'd reach out to this group to see if there are any suggestions.