title: How to properly terminate a QThread from a GUI application?
body: <p>I tried using <code>self.terminate()</code> in the QThread class, and also <code>self.thread.terminate()</code> in the GUI class. I also tried putting <code>self.wait()</code> in both cases. However, there are two scenarios that happen:</p>
  
  <p>1) The thread does not terminate at all, and the GUI freezes waiting for the thread to finish. Once the thread finished, the GUI unfreezes and everything is back to normal.</p>
  
  <p>2) The thread indeed does terminate, but at the same time it freezes the entire application.</p>
  
  <p>I also tried using <code>self.thread.exit()</code>. No joy.</p>
  
  <p>To further clarify, I am trying to implement a user-abort button in GUI which would terminate the executing of the thread at any point in time.</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT:</p>
  
  <p>Here is the <code>run()</code> method:</p>
  
  <pre><code>def run(self):
      if self.create:
          print "calling create f"
          self.emit(SIGNAL("disableCreate(bool)"))
          self.create(self.password, self.email)
          self.stop()            
          self.emit(SIGNAL("finished(bool)"), self.completed)
  
  def stop(self):
       #Tried the following, one by one (and all together too, I was desperate):
       self.terminate()
       self.quit()
       self.exit()
       self.stopped = True
       self.terminated = True
       #Neither works
  </code></pre>
  
  <p>And here is the GUI class' method for aborting the thread:</p>
  
  <pre><code>def on_abort_clicked(self):
       self.thread = threadmodule.Thread()
       #Tried the following, also one by one and altogether:
       self.thread.exit()
       self.thread.wait()
       self.thread.quit()
       self.thread.terminate()
       #Again, none work
  </code></pre>