title: Python PyQt callback never runs - how to debug?
body: <p>I have a fairly complicated piece of code using PyQt4 and sometimes my signal callbacks simply never run.</p>
  
  <p>It seems to be related to where/when I register the callbacks, ie. <code>self.someobj.somesig.connect(self.callback)</code>.</p>
  
  <p>I can see in the debugger that the callback is connected and that the signal es emitted.</p>
  
  <p>The code is too large to post here, but I will try to summarize:</p>
  
  <pre><code>class RC(QtCore.QObject):
    render_ready = QtCore.pyqtSignal(object)
    def __init__(self, pc, ...):
      super(RC, self).__init__()
      self.pc = pc
      self.pc.rr.new_render.connect(self.insert)
    def check(self):
      ...
      if a: self.pc.replot_request.emit()
      else: self.pc.render_request.emit()
    def insert(self, r):
      ...
      if b: self.render_ready.emit(r)
      self.check()
  
  class RR(QtCore.QObject):
    new_render = QtCore.pyqtSignal(object)
    def __init__(self, pc, app,...):
      super(RR, self).__init__()
      self.app = app
      self.pc = pc
    def run(self):
      self.pc.replot_request.connect(self.on_replot_request)
      self.pc.render_request.connect(self.render)
    ...
    def render(self, scale):
      ...
      r = R(i)
      r.moveToThread(QtGui.QApplication.instance().thread())
      r.new_render.emit(r)
  
  class R(QtCore.QObject):
    def __init__(self, i):
      super(R, self).__init__()
      ...
    ...
  
  class PC(QtCore.QObject):
    render_request = QtCore.pyqtSignal(int)
    replot_request = QtCore.pyqtSignal(object)
    def __init__(self, container, app):
      super(PC, self).__init__()
      ...
      self.rr = RR(self.app)
      self.rr_thread = QtCore.QThread()
      self.rr.moveToThread(self.rr_thread)
      self.connect(self.rr_thread, QtCore.SIGNAL("started()"), self.rr.run)
      self.c = RC(self)
      ...
      self.c.render_ready.connect(self.on_nr)
    def start(self):
      self.rr_thread.start()
    def on_nr(self, r):
      print "on_nr(...)"
  
  class App(QtCore.QObject):
    ...
    def __init__(self):
      ..
      self.pc = PC(container, app)
      ...
      self.pc.start(self)  # Last thing in constructor
  
  X = QtGui.QApplication(sys.argv)
  a = App()
  sys.exit(X.exec_())
  </code></pre>
  
  <p>I see <code>render_ready</code> being connected to <code>on_nr</code> and the <code>render_ready</code> being emitted. But <code>on_nr</code> never runs. The signal sequence is complicated, it goes across threads, but the signal and callback in question are in the same thread. Also, the event loop is clearly running. How could I start digging deeper? Or am I making some evident mistake? Thanks.</p>