Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2921

Signal slot not called due to race condition

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.8.0
    • PySide
    • None
    • macOS, Windows

    Description

      There seems to be a race condition preventing slots to be called immediately in 6.8. The code below works for all versions below I've tested, but with 6.8 the callback is never executed. Workarounds are moving the signal creation outside run(), or adding a sleep() to the end of task() (hence the assumption it's a race condition).

      from PySide6 import QtCore, QtWidgets
      
      QtWidgets.QApplication()
      
      class Signal(QtCore.QObject):
          result = QtCore.Signal()
      
      def run():
          signal = Signal()
          def task() -> None:
              print("task")
              signal.result.emit()
          def done() -> None:
              print("done") # never executes with 6.8
          signal.result.connect(done)
          QtCore.QThreadPool.globalInstance().start(task)
      
      run()
      

      Attachments

        1. pyside2921.py
          0.8 kB
        2. pyside2921-1.py
          1.0 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            rumo Georg Meier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes