How do you wait for a qthread to finish without blocking the main loop (thereby blocking the responsiveness of the main window)? I'm using PyQt5.

Qt Code:
  1. # When scan button is pressed
  2. def scan(self, e):
  3. for dev in self.deviceList:
  4. thread = TestThread(self, dev)
  5. thread.debugOutput.connect(self.updateTextEdit)
  6. thread.start()
  7. print("Thread finished")
To copy to clipboard, switch view to plain text mode 

The thread(s) started in this piece of code do GUI updates to inform the user of what's going on. I do not want to block that. I want the "thread finished" to be printed out once the thread actually is finished.