Actually, I got over the problem with that ENOMEM crash that tends to happen one good iteration after the token refresh. I added a gc.collect() directly before the token refresh just for kicks, and that solved the crash problem. Looks like the same code do not always use up the same amount of memory. It was totally not expected since the crash occurs in the urequest.get call which was right after a gc.collect(). No reason that call can run out of memory.
Now I am on to the next problem where the same urequest.get() will randomly return an invalid JSON string causing a crash in the subsquent parsing. Now I have to use nested try...except blocks to get anound this problem. My other problem with OSError 103 still occurs randomly, but more infrequently like every 6 hours for my 20 second loop. That get's taken care of by my outer try-except block. And if it gets sticky like failing on every successive call, then I have to resort to machine.reset() to restart the code. PuTTy works better than Thonny here. Although it looses communication with the COM port after the reset, I can reestablish the communication by restarting PuTTy. This way, I can confirm that the code is still running. Thonny cannot connect if the PICO is already running.
Working with Micropython has been an ongoing challenge. Better than a jigsaw puzzle.
Now I am on to the next problem where the same urequest.get() will randomly return an invalid JSON string causing a crash in the subsquent parsing. Now I have to use nested try...except blocks to get anound this problem. My other problem with OSError 103 still occurs randomly, but more infrequently like every 6 hours for my 20 second loop. That get's taken care of by my outer try-except block. And if it gets sticky like failing on every successive call, then I have to resort to machine.reset() to restart the code. PuTTy works better than Thonny here. Although it looses communication with the COM port after the reset, I can reestablish the communication by restarting PuTTy. This way, I can confirm that the code is still running. Thonny cannot connect if the PICO is already running.
Working with Micropython has been an ongoing challenge. Better than a jigsaw puzzle.
Statistics: Posted by nanowizz — Thu Jan 18, 2024 6:33 am