-1

On my code I'm getting RecursionError: maximum recursion depth exceeded and only clue that I'm getting from a traceback is File "q.py", line 523, in __init__ self.background = Background(source='images/space.png') repeated like 30 times. I checked the line but can't see anything wrong with it. I should also mention that this error occurred out of the blue. The code worked flawlessly.

Is there a way how to determine what exactly is causing it ? I'm aware that recursion usually means that some function is calling itself but I haven't found anything. Can't share the code because it's extensive.

1 Answers1

0

Your recursion goes too deep - this might be a problem with your break condition or with your algorithm and the data it operates on. If you "do not use" recursion - your code is at fault and we can not help much without seeing a MVCE of it.

You can increase the recursion size, see What is the maximum recursion depth in Python, and how to increase it?

If your algorythm works for smaller data sets and only crashes for bigger ones, you should probably search for a non-recursive solution to it.

Giving better advice without an mvce that replicates the algo and data that creates this error is difficult.

Read How to debug small programs (#2) - see if you can somehow locate the portion of code that recurses and fix it.

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
  • Yeah I know, not really an answer, but too long for the comments. I also voted to close the Q as too broad (and probably not fixable for SO with the amount of data provided...) – Patrick Artner Apr 06 '18 at 10:08
  • I knew this question wasn't best to ask like this. And I was expecting some downvotes but I was desperate. Been trying to fix this sudden problem for 3 days. I wish there was some debug program that would pinpoint the troubling line or lines. I checked all my functions several times. I'll try to increase the recursion size if that will make any difference. – Dan Lambert Apr 06 '18 at 10:10
  • @DanLambert Increasing the recursion size is a solution if your Algo works for lists of 100 pieces put not for 150 pieces due to recursion size - and you do not apply it to much bigger lists and by increasing it it then works for your aglo and your max data size. If your code "Worked" and suddenly "Does not work" and you do not use Recursion to solve something in it. increasing the rec_size _does solve nothing_ - you have to fix the part that is causing your unwanted recursion. – Patrick Artner Apr 06 '18 at 10:12
  • I know my friend. That's what's puzzling me so much and almost didn't sleep last night. I'm not messing with recursion on purpose or for learning purposes. My app is almost finished and this is holding me back. I gotta improve my debugging skills. Just a thought here. Do you think using Pycharm would help ? From what I know Pycharm comes with a debugger. – Dan Lambert Apr 06 '18 at 10:21
  • @DanLambert using _any_ debugger would be helpfull - regardless of if it is VS or PyCharm or any other one. Choose one, use it. You find lists of them f.e. here: https://wiki.python.org/moin/PythonDebuggingTools or you can use pdb: https://docs.python.org/3/library/pdb.html – Patrick Artner Apr 06 '18 at 10:23
  • Thanks so much for your input. Out of all who has seen my question you're the only one who was willing to give me some tips and ideas how to solve this problem despite of lack of details in my question. Immensely appreciated. I tried to vote you up to give you some recognition but I'm not allowed. Enjoy your day ! – Dan Lambert Apr 06 '18 at 10:41