After the change to catch BaseException in ddebb245e29b2649af4e69a7c098f8021144cc01, whenever the QtPy is about to enter deep sleep with USB connected to stable power source such as my laptop, it results in safe mode and the QtPy has to be restarted with the reset button.
It seems that the safe mode is a result of the marked line:
except BaseException as e: # pylint: disable=broad-except
# This assumes that such exceptions are quite rare.
# Otherwise, this would drain the battery quickly by restarting
# over and over in a quick succession.
watchdog.deinit()
print("Code stopped by unhandled exception:")
print(traceback.format_exception(None, e, e.__traceback__)) # !!! likely microcontroller crash
Because the last thing I can see, and I had to actually record this on video on my smartphone to be able to see what gets printed because screen exits when this happens (the autodetach off setting would have helped as a learned later), is the Code stopped by unhandled exception: which is the line right before that.
When I changed the BaseException to Exception, the problem does not happen anymore.
My hypothesis is that the DeepSleepRequest exception is raised and that does not bode well for the traceback for some reason. This is CircuitPython bug I believe. Anyhow, this means catching the BaseException is not safe so this has to be reverted.
After the change to catch
BaseException
in ddebb245e29b2649af4e69a7c098f8021144cc01, whenever the QtPy is about to enter deep sleep with USB connected to stable power source such as my laptop, it results in safe mode and the QtPy has to be restarted with the reset button.It seems that the safe mode is a result of the marked line:
Because the last thing I can see, and I had to actually record this on video on my smartphone to be able to see what gets printed because
screen
exits when this happens (theautodetach off
setting would have helped as a learned later), is theCode stopped by unhandled exception:
which is the line right before that.When I changed the
BaseException
toException
, the problem does not happen anymore.My hypothesis is that the
DeepSleepRequest
exception is raised and that does not bode well for the traceback for some reason. This is CircuitPython bug I believe. Anyhow, this means catching theBaseException
is not safe so this has to be reverted.