title: How to (properly) update a worker QThread with new connection settings?
body: <p>Suppose I have a QThread for running a plugin in my app and the plugin connects to a server specified by the user. When the user changes the server settings, the plugin should connect to the new server - as expected. Would it be a good idea to simply terminate the current plugin worker thread and spin up a new one when the user updates the settings?</p>
  
  <p>This is what I've got at the moment</p>
  
  <pre><code>class MainWindow(QMainWindow):
      def __init__(self):
          # ...
          self.hostname.editingFinished.connect(
              lambda: self._setup_new_server() or
                      self._restart_plugin_work_thread()
              )
          self.port.editingFinished.connect(
              lambda: self._setup_new_server() or
                      self._restart_plugin_work_thread()
              )
  
      def _create_plugin_worker_thread(self):
          self.plugin_worker_thread = QtCore.QThread()
          self.plugin_worker = PluginWorker()
          self.plugin_worker.moveToThread(self.plugin_worker_thread)
          self.plugin_worker_thread.start()
          self.plugin_worker.run_plugin_signal.connect(self.plugin_worker.run_plugin)
          self.plugin_worker.stop_plugin_signal.connect(self.plugin_worker.stop_run_plugin)
  
      def _terminate_plugin_worker_thread(self):
          self.plugin_worker_thread.terminate()
  
      def _restart_plugin_work_thread(self):
          # terminate the current worker thread
          self._terminate_plugin_worker_thread()
          # create a new worker thread
          self._create_plugin_worker_thread()
  
  class PluginWorker(QtCore.QObject):
      run_plugin_signal = QtCore.Signal(str, int, str, str)
      stop_plugin_signal = QtCore.Signal()
      # ...
  </code></pre>
  
  <p><code>PluginWorker</code> is the worker class which mostly relies on a <code>QTimer</code> that triggers the plugin's execution method every 2 seconds.
  Any help will be appreciated. Thanks.</p>