[PySide] Signals and recursion

Safa Alfulaij safa1996alfulaij at gmail.com
Tue Sep 1 10:51:30 CEST 2020

Hello world

I have an object with a notifiable property "value".
I also have 1000+ instances, each has the previous object's property signal
connected to it's slot.

In my testing, I exceed the recursion depth at around object 200.
It seems that each "emit" pauses the execution, goes to the receiver to
emit, and so on, which creates new stack frames.

Any way to "solve" this? Thanks!

Ps. I'm not subscribed. Please CC me.


from PySide2.QtCore import *
from PySide2.QtGui import *

class TestObject(QObject):
    valueChanged = Signal('QVariant')

    def __init__(self, *value, name):
        super(TestObject, self).__init__()
        self._value = value
        self._name = name

    @Property('QVariant', notify = valueChanged)
    def value(self):
        return self._value

    def set_value(self, value):
        if self._value == value:

        self._value = value
        print(f'Emitting {self._name}')
        self.valueChanged.emit(value) # Recursion here
        print(f'Stopping {self._name}')

    def update_value(self, value):

    def set_dependency(self, test_object):

# create linked objects (obj1-> obj2-> obj3-> obj4-> ... -> obj1999
test_objects = []
for x in range(2000):
        TestObject(x, name=f'test{x}')
    if x != 0:

# update first object, emitting signal to next object, and next, and next,
test_objects[0].value = 100
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20200901/1889c5e2/attachment.html>

More information about the PySide mailing list