title: PyQt Dialog not responsible while thread running
body: <p>I want to show loading progress via a modal <code>QDialog</code>. So I create a thread to load the data and call <code>exec()</code> on the dialog.</p>
  
  <pre><code>loading_progress_dialog = LoadingProgressDialog(len(filenames))
  loadingWorker = analyzer.LoadingWorker(filenames, loading_progress_dialog.apply_progress)
  workingThread = QThread()
  
  workingThread.started.connect(loadingWorker.process)
  loadingWorker.finished.connect(workingThread.quit)
  workingThread.finished.connect(loading_progress_dialog.accept)
  
  loadingWorker.moveToThread(workingThread)
  workingThread.start()
  
  loading_progress_dialog.exec()
  </code></pre>
  
  <p>I want the dialog to be responsible but it freezes and I'm not able to move it around on the screen while the loading thread is running.</p>
  
  <pre><code>class LoadingProgressDialog(QLoadingProgressDialog, Ui_LoadingDialog):
      def __init__(self, maxFiles):
          super(LoadingProgressDialog, self).__init__()
          self.setupUi(self)
  
          self.progressBar.setMaximum(maxFiles)
          self.setWindowTitle('Loading files...')
  
      def apply_progress(self, delta_progress):
          self.progressBar.setValue(delta_progress + self.progressBar.value())
  
  class LoadingWorker(QtCore.QObject):
      def __init__(self, file_names, progress_made):
          super(LoadingWorker, self).__init__()
          self._file_names = file_names
          self._progress_made = progress_made
  
      finished = QtCore.pyqtSignal()
  
      def process(self):
          print("Thread started")
          # load_csv_data(self._file_names, self._progress_made)    
          QtCore.QThread.sleep(5)
          self.finished.emit()
  </code></pre>
  
  <p>Am I fighting with GIL or is it another problem? And second thing I am worried about is race-condition between <code>self.finished.emit()</code> and <code>loading_progress_dialog.exec()</code>. If the working thread is finished faster than gui thread runs <code>exec()</code>, the dialog will not close. Is there any way to ensure that everything is in right order?</p>