title: PyQt5 Signal Between Classes Causing Lockup
body: <p>I'm trying to send signals between classes, which works fine from the HMI class to the WorkerThread class, but causes a program lockup, or infinite loop, when WorkerThread tries to connect to a signal from the HMI class. </p>
  
  <pre class="lang-py prettyprint-override"><code>import sys
  import time
  
  import PyQt5
  from PyQt5 import QtCore, QtWidgets
  from PyQt5.QtCore import QThread
  from PyQt5.QtWidgets import QWidget, QApplication
  
  from Home import Ui_HomeWin     # PyQt5 Designer window
  
  class WorkerThread(QThread):
      hmiHandlesThis = PyQt5.QtCore.pyqtSignal(str)
      def __init__(self, parent=None):
          super(WorkerThread, self).__init__(parent)
          self.counter = 0
  
          # this attempted connection causes a lockup
          self.HMI_Thread = HMI()     # appears to be a recursive loop
          self.HMI_Thread.updateGlobals.connect(self.update_global_widgets)
  
      def run(self):
          while True:
              time.sleep(0.5)
              print('Doing a bunch of other stuff: {}'.format(self.counter))
              self.counter += 1
  
      def build_a_command(self):
          print('building a command...')
          name = 'pbAutoMode'
          # example command
          command = name + '.setStyleSheet("QPushButton{ background-color: rgb(0, 0, 255); }")'
          self.hmiHandlesThis.emit(command)
  
      def update_global_widgets(self):
          print('update some global widgets')
  
  class HMI(QWidget):
      updateGlobals = PyQt5.QtCore.pyqtSignal(name='updateGlobals')
      def __init__(self, parent=None):
          super(HMI, self).__init__(parent)
  
          self.HomeWin = QtWidgets.QDialog()
          self.HomeWin.setWindowFlags(QtCore.Qt.FramelessWindowHint)
          ui = Ui_HomeWin()
          ui.setupUi(self.HomeWin)
          self.HomeWin.show()
  
          # this connection works
          self.workerThread = WorkerThread()
          self.workerThread.hmiHandlesThis.connect(self.on_new_command)
          self.workerThread.start()
  
      def on_new_command(self, command):
          print('New command is: {}'.format(command))
  
  if __name__ == '__main__':
      app = QApplication(sys.argv)
      ex = HMI()
      sys.exit(app.exec_())~~~
  </code></pre>
  
  <p>I've tried placing the signal definitions inside the <strong>init</strong> functions, with no difference.</p>