Issue402

Title Problems accessing internet with compiled app and recursionerrors
Priority urgent Status resolved
Superseder Nosy List frankieee
Assigned To Keywords unsupported

Created on 2018-05-29.13:42:30 by frankieee, last changed by kayhayen.

Messages
msg2425 (view) Author: kayhayen Date: 2018-07-10.12:37:43
Thanks for your opinion.

Yours,
Kay
msg2412 (view) Author: frankieee Date: 2018-06-01.16:18:01
Oh and btw i see you said pyside was unsupported for standalone mode, but im 
getting problems running threads on "normal" mode too, so you might want to look 
into that.
msg2411 (view) Author: frankieee Date: 2018-06-01.16:14:24
I wouldnt be so quick to conclude. For myself i am working on a commercial app with hidden 
sourcecode. I made the choice because the market im working against is full of scammers who i 
know wouldnt spend one second to resell my software if it automatically worked on every 
computer.

Despite that i have contributed many patches to one of the open-source libraries that i use 
in my software(crypto).

I know there's an idea in the open-source world that everything must be open source or you 
are evil but atleast for me as a single developer i decided against open-sourcing my program 
and selling it due to the nature of the people in the market i will be selling against. Right 
or wrong, we're not all evil stereotypical microsoft supporting statists. Some of us are just 
trying to make ends meet and are immediately chastised for it is seems.
msg2408 (view) Author: kayhayen Date: 2018-06-01.08:22:34
Hello,

for PySide, patches are needed. These were submitted years ago, and never got merged due to lack of manpower. 
You might want to search Nuitka mailing list archives on that topic.

I started ignoring PySide myself. I consider PySide unsupported for standalone mode.

Maybe eventually I will document that. But it seems PySide is only used by people who want to not pay for PyQt 
anyway. And that's not the people who are intent on helping with Free Software anyway, so I don't care too 
much.

Yours,
Kay
msg2407 (view) Author: frankieee Date: 2018-05-29.23:07:55
Posted bug here: https://bugreports.qt.io/browse/PYSIDE-674
msg2406 (view) Author: frankieee Date: 2018-05-29.22:29:05
I tried it with pyqt5 now. It works perfectly. Perhaps this is a pyside2 bug. If 
you can help those guys out(it's opensource too!) then we can all praise jebus.
msg2405 (view) Author: frankieee Date: 2018-05-29.19:01:10
I managed to make a minimal example:

from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Slot, Signal, QThread
import sys
import requests
import time

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(240, 100, 97, 34))
        self.pushButton.setObjectName("pushButton")
        self.plainTextEdit = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit.setGeometry(QtCore.QRect(200, 160, 451, 271))
        self.plainTextEdit.setPlainText("")
        self.plainTextEdit.setObjectName("plainTextEdit")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 30))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.pushButton.setText(_translate("MainWindow", "OK"))

class MainUIClass(QtWidgets.QMainWindow, Ui_MainWindow):
    def closeEvent(self, evnt):
        print("CLOSED")
        self.thread1.quit()
        self.thread2.quit()
        self.thread3.quit()
        self.thread1.wait()
        self.thread2.wait()
        self.thread3.wait()
        print("thread1 is running?:", self.thread1.isRunning())
        print("thread2 is running?:", self.thread2.isRunning())
        print("thread3 is running?:", self.thread3.isRunning())
        sys.exit()
        
    def __init__(self, parent=None):
        super().__init__()
        self.setupUi(self)

        self.thread1 = QThread()
        self.thread2 = QThread()
        self.thread3 = QThread()

        self.Class1 = Class1()
        self.Class2 = Class2()
        self.Class3 = Class3()

        self.Class1.moveToThread(self.thread1)
        self.Class2.moveToThread(self.thread2)
        self.Class3.moveToThread(self.thread3)

        self.thread1.started.connect(lambda: self.Class1.startThread())

        self.Class1.startThread2.connect(self.Class2.startThread)
        self.Class2.startThread3.connect(self.Class3.startThread)
        self.Class3.startThread1.connect(self.Class1.startThread)

        self.thread1.start()
        self.thread2.start()
        self.thread3.start()

class Class1(QtCore.QObject):
    startThread2 = Signal()

    def __init__(self):
        super().__init__()

    @Slot()
    def startThread(self):
        time.sleep(1)
        data = requests.get("https://www.google.com")
        print("thread1:", data)
        self.startThread2.emit()

class Class2(QtCore.QObject):
    startThread3 = Signal()

    def __init__(self):
        super().__init__()

    @Slot()
    def startThread(self):
        time.sleep(1)
        data = requests.get("https://www.google.com")
        print("thread2:", data)
        self.startThread3.emit()

class Class3(QtCore.QObject):
    startThread1 = Signal()

    def __init__(self):
        super().__init__()

    @Slot()
    def startThread(self):
        time.sleep(1)
        data = requests.get("https://www.google.com")
        print("thread3:", data)
        self.startThread1.emit()

a = QtWidgets.QApplication(sys.argv)
app = MainUIClass()

a.setQuitOnLastWindowClosed(False)
app.setWindowTitle("Pyside2 thread compiled test")
app.show()

sys.exit(a.exec_())

This code will work perfectly before you compile it with cython or nuitka. If you compile it with cython it will output:

('thread1:', <Response [200]>)
RecursionError: maximum recursion depth exceeded while calling a Python object
and hang but it will show the window contents. With nuitka it will never show the contents of the window but the threads will run as expected. If anyone can 
explain why it happens and how i can fix it that would be great.
msg2404 (view) Author: frankieee Date: 2018-05-29.13:42:28
Hi im just posting from: https://stackoverflow.com/questions/50582560/when-i-compile-my-python-code-i-get-recursionerror-maximum-
recursion-depth-exc although this is understandably both a nuitka and cython issue:

"Latest version of cython. My app works fine when i run it with python but when i make it into a module and import the module from 
a simple launcher script suddenly it doesn't seem to see any data from the internet and it also gives me these: RecursionError: 
maximum recursion depth exceeded while calling a Python object.

Nuitka has the same problem but doesn't give me these recursionerrors. It's a proprietary app and i can't give away the sourcecode 
but if you have any ideas they will be greatly appreciated.

I have no idea if it's relevant but when compiling the program(making object code) with gcc i also get this error/warning/note(the 
only one):

$ python setup.py build_ext --inplace
Compiling prog.py because it changed.
[1/1] Cythonizing prog.py
running build_ext
building 'prog' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 
-Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -
fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -
pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -
O2 -pipe -fstack-protector-strong -fno-plt -fPIC -
I/usr/include/python3.6m -c prog.c -o build/temp.linux-x86_64-
3.6/prog.o
prog.c: In function ‘__pyx_pf_4prog_13Ui_MainWindow_setupUi.isra.76’:
prog.c:41235:18: note: variable tracking size limit exceeded with -
fvar-tracking-assignments, retrying without
static PyObject *__pyx_pf_4prog_13Ui_MainWindow_setupUi(CYTHON_UNUSED 
PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_MainWindow) {
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Nuitka doesn't give this note(or atleast i can't see it).

Also not sure if relevant but i have a bunch of classes(pyside2 threads) that calls the next class when one is finished making a 
loop. Maybe this is a nono even if it works fine in python?

I'm using pyside2, requests, delorean and humanize. Im not even sure how to start debugging this, it's a 4000 line program.

edit: it seems the real problem is not being able to access stuff from the internet although this is only a tentative hypothesis. 
After all with nuitka i get no recursion errors but both seem to have problems getting json data from the internet...
History
Date User Action Args
2018-07-10 12:37:43kayhayensetstatus: chatting -> resolved
messages: + msg2425
2018-06-01 16:18:01frankieeesetmessages: + msg2412
2018-06-01 16:14:24frankieeesetstatus: resolved -> chatting
messages: + msg2411
2018-06-01 08:22:35kayhayensetstatus: chatting -> resolved
messages: + msg2408
keyword: + unsupported
2018-05-29 23:07:55frankieeesetmessages: + msg2407
2018-05-29 22:29:06frankieeesetmessages: + msg2406
2018-05-29 19:01:10frankieeesetstatus: unread -> chatting
messages: + msg2405
2018-05-29 13:42:30frankieeecreate