I’m building a dashboard for my unicorn. It cycles between some screens, and periodically refreshes its info from two rest calls.
I was using urequests initially, but was getting out of memory errors relatively quickly. I switched to urllib.urequest, which got rid of the memory errors, but now it runs for about an hour before freezing.
I was able to capture a freeze while connected to Thonny, and it says:
Traceback (most recent call last):
File "<stdin>", line 402, in <module>
File "trains_azure.py", line 37, in get_timetables
File "trains_azure.py", line 21, in query
File "/lib/urllib/urequest.py", line 30, in urlopen
OSError: (-29312, 'MBEDTLS_ERR_SSL_CONN_EOF')
Googling isn’t telling me much about this error. What could it be? This request goes through ok multiple times before failing. (There’s a 9min cooldown on refreshing the network data)
Memory seems pretty stable. I’m gc.collect()ing between each network call, and before the final call it’s reporting around 55k bytes free.
Alternatively, how can I make micropython detect and recover from an OSError? I’m ok with just hard-resetting the device at that point, if it’s once an hour or more.
The source is here if it helps GitHub - tenpn/unicorn – the crash I intercepted was on the urlopen in trains_azure.py.