title: In PyQT how to store data emitted from signal in QRunnable
body: <p>I have a process that takes awhile in a PyQT4 application using Python3.  So I have been investigating using threading to speed it up.  The data can easily be broken part and processed in a loop.  I am using a custom <code>QRunnable</code> where you can pass a target function and args which is then fed into a <code>QThreadpool</code>.   I use a <code>pyqtSignal</code> to emit the processed data from each worker.  The Data is being received by my slot but it isn't being stored.  Below is an cut down example of what I have attempted.  </p>
  
  <pre><code>import sys, time
  from random import uniform
  from PyQt4 import QtCore, QtGui
  
  class AWorker(QtCore.QRunnable):
      """ Generic Task for ThreadPool to execute required Kwargs =
      target (&lt;function&gt;): function to call
      args  (tuple): args for target
      kwargs (dict): kwargs for target """  
      def __init__(self, target=None, args=(), kwargs={}):
          super(AWorker, self).__init__()
          self.target = target 
          self.args = args
          self.kwargs = kwargs
      def run(self):
          self.target(*self.args, **self.kwargs)
  
  class myTest(QtCore.QObject):  
  
      doneSignal = QtCore.pyqtSignal(int)  #Create a signal to emit the data
  
      def __init__(self):
          super(myTest, self).__init__()        
          self._procData = [] #Place to Store data .. maybe        
          self.pool = QtCore.QThreadPool.globalInstance()
          self.pool.setMaxThreadCount(4) #Use up to 8 threads
  
      def runAll(self):
          self.doneSignal.connect(self.storeData) 
          for data in range(4):
              worker = AWorker(target=self.processData, args=(data,))
              self.pool.start(worker)    
  
      def processData(self,data):        
          print('Crunching ...', str(data))
          outData = data+10
          time.sleep(uniform(1,3))  #Simulate this taking a random amount of time
          self.doneSignal.emit(outData)
  
      def storeData(self,data):        
          print('Received ...', str(data))
          self._procData.append(data)
  
      def getData(self):
          return self._procData
  
  if __name__ == '__main__':
      app = QtGui.QApplication(sys.argv)
      test = myTest()
      test.runAll()
      test.pool.waitForDone()
      print('All done ... and the data is: ',test.getData())
      app.exec_()
  </code></pre>
  
  <p>It runs and from the print outs the following:</p>
  
  <pre><code>Crunching ... 0
  Crunching ... 1
  Crunching ... 3
  Crunching ... 2
  All done ... and the data is:  []
  Received ... 13
  Received ... 11
  Received ... 12
  Received ... 10
  </code></pre>
  
  <p>Ok, so the signals aren't emitted until after they all finish? maybe?  or I can't assign to <code>_procData</code> since I am in a different thread or something? I tried removing the <code>waitForDone()</code> just to see but that as expected didn't help.</p>
  
  <p>So what is the proper way to assemble the data output from each worker?  And I suppose a follow up question, how do you ensure it is put back in the correct order.</p>