maximum recursion depth



  • I know this has been asked elsewhere, but the answer I require hasn't appeared.

    My code, which uses threads but has no (intentionally) recursive calls, is throwing "maximum recursion depth exceeded" exceptions.

    Using this test :

    def recursion_check(count):
        ## https://forum.micropython.org/viewtopic.php?t=3091
        try:
            return recursion_check(count+1)
        except:
            return count
    

    I can see that without threads, the recursion depth is 49 (or more likely 50).

    When run inside a thread, the above code returns a paltry 10, regardless of the number of threads or the stack size, which I've tried resetting with _thread.stack_size(16 * 1024) (my board is an ESP32 with additional 64Mbit PSRAM).

    I think this exception is being thrown because a call stack limit is being hit, and has nothing to do with recursion. My code paths are predictable , with few differences between ones that succeed and ones that don't.

    On this basis, I'd like to increase the 'call stack limit, which would seem to be hard coded somewhere in the MP source. I've searched in the usual places, but come up empty handed.

    Could someone please point the way to this mod?

    Without too many suggestions along the lines of converting function calls to loops or not using threads, thanks. :-)


Log in to reply
 

Pycom on Twitter