The code is pulling data from the Purple Air and Weather Underground web sites. It will run for a while (frequently hours) and then crash in a fetch_data() call. I have a try/except clause around the fetch_data(), but for some reason it only catches the error occasionally.
Here is the error:
Retrieving data...Traceback (most recent call last):
File "code.py", line 126, in <module>
File "code.py", line 122, in <module>
File "adafruit_portalbase/network.py", line 453, in fetch_data
File "adafruit_portalbase/network.py", line 425, in fetch
File "adafruit_requests.py", line 612, in get
File "adafruit_requests.py", line 576, in request
File "adafruit_requests.py", line 436, in _get_socket
OSError: 0
This is coming from this section of the code (full code attached):
- Code: Select all | TOGGLE FULL SIZE
print("***inside")
fetch_success = False
try:
inside = NETWORK.fetch_data(
url=Inside_SOURCE,
json_path=(PM2_Location,TEMP_Location,HUMI_Location),)
fetch_success = True
except RuntimeError as e:
print("Some error occurred, retrying! -", e)
continue
I have seen the try/except actually catch the error on some iterations. For example, this will pop up every now and then:
***inside
Retrieving data...Some error occurred, retrying! - Sending request failed
Free Memory: 1,946,496
Iteration: 13
Any thoughts on ways that I can track this down?
I'll also file this as an issue as siddacious suggested in the original post.