Closed vladak closed 1 year ago
When catching Exception
(such as the ConnectionError
that is based on OSError
that is based on Exception
), the code performs supervisor.reload()
and exits the program, so that it can be run again thanks to the auto reload. It seems there is a resource leak (and possibly some other problem because it never recovers even though other microcontrollers can connect to the same wifi network just fine in the mean time) in the microcontroller firmware because after number of these it results in the MemoryError
.
One way to deal with this would be to do microcontroller.reset()
instead of supervisor.reload()
on ConnectionError
to avoid the MemoryError
later on. Alternatively, add a try/except block around the import wifi
statement. The latter would not work too well with the planned logging changes in #12.
One of the QtPy's (ESP32 based with uFL and external antenna) running the code from this repository enters a state of exception (blinking the red diode twice every 5 seconds or so) after running for a day or so. Attaching a terminal reveals this:
So, basically there was a singular case of
MMQTTException
(due to not receiving any data from the broker for 10 seconds) followed by couple ofConnectionError
cases (27 in total) followed byMemoryError
whenimport wifi
was executed (this is the line number 30 incode.py
).In the meantime, I broadened the
except
block in the code via ddebb245e29b2649af4e69a7c098f8021144cc01, however that would have not helped because the exception is raised from an import that is not covered by the try/except blocks.