def get_current_worker_and_state(self):
        """
        Get the current thread and its associated state.
        :return:
        :rtype: (ShBaseThread, ShState)
        """
        current_worker = threading.currentThread()
        if isinstance(current_worker, ShBaseThread):
            return current_worker, current_worker.state
        else:  # UI thread uses runtime for its state
            return None, self.state

        Get the current thread and its associated state.
        :return:
        :rtype: (ShBaseThread, ShState)
        
system/shruntime.py