title: Quit when QThreadPool not empty?
body: <p>I have a lot of long running tasks that run in the background of my Python app. I put them all in the global <code>QThreadPool</code>. When the user quits, all of those background tasks need to stop.</p>
  
  <p>Right now, I have the following code:</p>
  
  <pre><code>app.aboutToQuit.connect(killAllThreads)
  
  def killAllThreads():
      QtCore.QThreadPool.globalInstance().waitForDone()
  </code></pre>
  
  <p>I've seen suggestions to add a global variable that says whether the application should be quitting, and to have threads terminate themselves, but this sounds like a terribly messy and inelegant solution. Would you really propose adding a check before every line of code in a background task to make sure that the application shouldn't be quitting yet? That's hundreds of checks that I would have to add.</p>
  
  <p>The suggestion seems to make the assumption that my tasks are simple and/or have complex clean ups involved, but actually, I have just the opposite: the tasks involve hundreds of lines of code, each of which can take several seconds, but no clean up needs to be done at all.</p>
  
  <p>I've heard simply killing the threads would be a bad idea, as then they wouldn't be guaranteed to clean up properly, but as no clean up is necessary, that's exactly what I want to do. Additionally, race conditions could occur, but again, the tasks need to stop right now, so I really don't care if they end up in an invalid state.</p>
  
  <p>So I need to know the following:</p>
  
  <ol>
  <li>How do I get a list of all the running threads in a <code>QThreadPool</code>?</li>
  <li>How do I have them abort what they're doing?</li>
  </ol>