Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    maximum recursion depth

    Scheduled Pinned Locked Moved MicroPython
    1 Posts 1 Posters 25 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      bitrat
      last edited by bitrat

      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. :-)

      1 Reply Last reply Reply Quote 1

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • 1 / 1
      • First post
        Last post

      Pycom on Twitter

      Pycom