Unreliability of http_req.get() on PICO W

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Hobbes4Pres
 
Posts: 5
Joined: Thu Dec 15, 2022 9:24 am

Unreliability of http_req.get() on PICO W

Post by Hobbes4Pres »

Using CyPy 8.0.3 and latest CyPy libraries from 3/11/23.

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
I capture the log in PuTTY. Randomly, I will get some errors, but then it recovers. Note that it throws a BaseException error, but when I print that out I get nothing.
-------------- 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
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.

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”