Important: Please read the Qt Code of Conduct -

Pyside QThreadPool problem

  • Hi! I have problem with QThreadPool. Then object derived from QRunnable contains some other object, program crush on exit (The instruction at "0x1e0154ac" referenced memory at "0x00000028". The memory could not be "read"). Here is a minimal code:

    -- coding: utf-8 --

    import sys
    from PySide.QtCore import *
    from PySide.QtGui import *

    class Test:
    def init(_self):

    class TestThread(QRunnable, QObject):
    def init(_self, _parent = None):
    QRunnable.init(_self, _parent)

    #if comment next line, all ok.
    _self.obj_ = Test()
    #_self.obj_ = "some text" - this working too.

    def run(_self):

    class Window(QMainWindow):
    def init(_self, _parent = None):
    QMainWindow.init(_self, _parent)

    _self.threadPool = QThreadPool()
    _self.threads = []
    for i in range(2):

    def testMethod(_self):
    for threadObj in _self.threads:

    if name == 'main':
    app = QApplication(sys.argv)
    form = Window()

    Edit: improved code style

  • By changing line 7:
    @class Test:@

    @class Test(object):@

    it's not running into segfaults anymore on my system.

    Using old-style classes (not using the ultimate 'object' base class) in Python is being discouraged for quite some time now and this makes me think PySide can't handle them, or this is just a bug.

Log in to reply