RuntimeError: maximum recursion depth exceeded

Discussion related to "under the hood" OpenMV topics.
Apollo22
Posts: 9
Joined: Fri Aug 11, 2017 5:14 am

RuntimeError: maximum recursion depth exceeded

Postby Apollo22 » Fri Aug 11, 2017 5:20 am

Hello,

I encountered the following error : RuntimeError: maximum recursion depth exceeded

Code: Select all

  File "<stdin>", line 3, in <module>
  File "fsm.py", line 4, in <module>
  File "can.py", line 7, in <module>
  File "can_motion_commands.py", line 3, in <module>
  File "cam_analysing.py", line 8, in <module>
RuntimeError: maximum recursion depth exceeded
How could I get around this error without merging files together ?

PS : in the terminal, you show "Type "help()" for more information.". How can I call it ? I can't write anything on the terminal.
Apollo22
Posts: 9
Joined: Fri Aug 11, 2017 5:14 am

Re: RuntimeError: maximum recursion depth exceeded

Postby Apollo22 » Fri Aug 11, 2017 8:49 am

I found a workaround.

Previously I only had in File 0 : " import File 1 "
Then File 1 imported File 2, File 2 imported File3, File 3 imported File 4 and File 4 import File 5.
And it printed " RuntimeError: maximum recursion depth exceeded "

The workaround is to import files that import less than 5 levels of import in it. In the previous exemple, import File 2, 3, 4, or 5 before File 1.

My import tree is messier because from 1 file I import several other files that imported each other. Allowing me to call global variables from any file. But I just have to first import the files that import other files with less than 5 level of recursion before importing those with more than 5.
User avatar
kwagyeman
Posts: 1025
Joined: Sun May 24, 2015 2:10 pm

Re: RuntimeError: maximum recursion depth exceeded

Postby kwagyeman » Fri Aug 11, 2017 12:00 pm

Wow, that's a lot of depth to your code. Good that you found a solution.
Nyamekye,
Apollo22
Posts: 9
Joined: Fri Aug 11, 2017 5:14 am

Re: RuntimeError: maximum recursion depth exceeded

Postby Apollo22 » Mon Aug 21, 2017 10:07 am

Is there a way for future implementation to increase the maximum recursion depth ?

For information, this is my current import tree. I manage to do with the current recursion depth, but it would be easier if it was bigger.
Import Tree.jpg
Import Tree.jpg (131.18 KiB) Viewed 87 times
User avatar
kwagyeman
Posts: 1025
Joined: Sun May 24, 2015 2:10 pm

Re: RuntimeError: maximum recursion depth exceeded

Postby kwagyeman » Mon Aug 21, 2017 11:53 am

This is a limit from the MicroPyhton environment. I'll need to search through the c code to find what the limit is set too. You can also ask this question on the MicroPyhton forums and they may be able to answer this more quickly.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests