      def set_session_summary(self, message):
          """ Set the summary data and info message """
          if self.thread is None:
              logger.debug("Setting session summary. (message: '%s')", message)
              self.thread = LongRunningTask(target=self.summarise_data, args=(self.session, ))
              self.thread.start()
              self.after(1000, lambda msg=message: self.set_session_summary(msg))
          elif not self.thread.complete.is_set():
              logger.debug("Data not yet available")
              self.after(1000, lambda msg=message: self.set_session_summary(msg))
 
</s> remove         elif not self.thread.complete.is_set():
 </s> add             return True
        if not self.thread.complete.is_set(): </s> remove         logger.debug("Updating plot")
        self.calcs.refresh()
        self.update_plot(initiate=False)
        self.plotcanvas.draw()
        get_config().tk_vars["refreshgraph"].set(False)
 </s> add         refresh_var = get_config().tk_vars["refreshgraph"]
        if not refresh_var.get() and self.thread is None:
            return

        if self.thread is None:
            logger.debug("Updating plot data")
            self.thread = LongRunningTask(target=self.calcs.refresh)
            self.thread.start()
            self.after(1000, self.refresh)
        elif not self.thread.complete.is_set():
            logger.debug("Graph Data not yet available")
            self.after(1000, self.refresh)
        else:
            logger.debug("Updating plot with data from background thread")
            self.calcs = self.thread.get_result()  # Terminate the LongRunningTask object
            self.thread = None
            self.update_plot(initiate=False)
            self.plotcanvas.draw()
            refresh_var.set(False) </s> remove         else:
            logger.debug("Getting Popup from background Thread")
            self.display_data = self.thread.get_result()
            self.thread = None
            if not self.check_valid_data():
                logger.warning("No valid data to display. Not refreshing")
                self.vars["status"].set("")
                return False
            logger.debug("Compiled Display Data")
            self.vars["buildgraph"].set(True)
 </s> add  </s> remove                 if self.process.poll() is not None:
 </s> add                 if process.poll() is not None:
            self.thread = LongRunningTask(target=self.summarise_data,
                                          args=(self.session, ),
                                          widget=self)
      def set_session_summary(self, message):
          """ Set the summary data and info message """
          if self.thread is None:
              logger.debug("Setting session summary. (message: '%s')", message)
            self.thread = LongRunningTask(target=self.summarise_data,
                                          args=(self.session, ),
                                          widget=self)
              self.thread.start()
              self.after(1000, lambda msg=message: self.set_session_summary(msg))
          elif not self.thread.complete.is_set():
              logger.debug("Data not yet available")
              self.after(1000, lambda msg=message: self.set_session_summary(msg))
keep keep keep keep replace keep keep keep keep keep
 GUI responsiveness and feature updates

- Add error handling to LongRunningTask
- Analysis: Fix timestats bug for missing session data
- Training: Update training graph inside LongRunningTask
- Training: Smoothing Amount Slider geometry fix
- Training: Auto update Analysis tab on training start and save interval
- Scripts: Keep control of the UI when terminating by terminating using LongRunningTask 
lib/gui/display_analysis.py