Home:ALL Converter>Python RecursionError on compiled scripts with Cython

Python RecursionError on compiled scripts with Cython

Ask Time:2017-10-06T16:56:49         Author:EinSoldiatGott

Json Formatter

I have a python application which runs perfectly on python but has an error when I run the cythonized scripts.

When I compile the scripts with cython everything compiles ok, I'm compiling on a Raspberry with Linux and running on it too.

setup.py

from distutils.core import setup 
from Cython.Build import cythonize
setup(ext_modules=cythonize(["*.py"]),)

Then I run the setup.sh to compile and I delete all the compiled *.py, *.c and *.pyc just to be sure that what is running is the compiled *.so files. I compile everything except my mainGUI.py it is PySide based and it always breaks while compiling.

setup.sh

sudo python3 ./setup.py build_ext --inplace
find . -name \*.py -delete
find . -name \*.c -delete
sudo rm -r ./__pycache__    
sudo rm -r ./build

Then I run my app

sudo python3 mainGUI.py

And everything seems to be ok, the GUI shows up, menus are working, but when I read the terminal I get this output many times:

RecursionError: maximum recursion depth exceeded while calling a Python object

But I don't know what script.py is throwing this. I've tried leaving some scripts.py out of the compilation and letting them run as .py (for example mySQLdatabaseScript.py) and the amount of RecursionError is reduced but not eliminated.

So even when my GUI runs, and seems without error, most of my functions are not working they throw the RecursionError.

I've read that I can increase the recursion limit

sys.setrecursionlimit(1500)

But where should I do this? in the mainGUI.py? Or on each script.py?

One thing that I can see in this process is that cython is not making my application optimized on memory :/

Thanks :)

Author:EinSoldiatGott,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46602015/python-recursionerror-on-compiled-scripts-with-cython
Ando :

I have same error. Exactly the same.\nI note this happens only when I use a pyside \"signal connect\" feature.\nFor example, using a timer to display a clock.\n\ntimer = QtCore.QTimer(self)\ntimer.timeout.connect(self.showTime) #will fail in every showTime Call\ntimer.start(1000)\n\n\nI've decided to not use a timer. Ok. It works for now.\nSame error when connect a double click. It's bad.\nSame error when connecting a radio button. \n\nUpdate: Solution, I moved to PyQt5, and planning to pay the license. \nThe Cythonized script works fine with signal - slot feature.",
2017-10-18T04:28:56
yy