code: def _execute_phase_once(self, phase_desc, is_last_repeat):
      
      # Check this before we create a PhaseState and PhaseRecord.
      if phase_desc.options.run_if and not phase_desc.options.run_if():
        _LOG.debug('Phase %s skipped due to run_if returning falsey.',
                   phase_desc.name)
        return PhaseExecutionOutcome(openhtf.PhaseResult.SKIP)
  
      override_result = None
      with self.test_state.running_phase_context(phase_desc) as phase_state:
        _LOG.debug('Executing phase %s', phase_desc.name)
        with self._current_phase_thread_lock:
          # Checking _stopping must be in the lock context, otherwise there is a
          # race condition: this thread checks _stopping and then switches to
          # another thread where stop() sets _stopping and checks
          # _current_phase_thread (which would not be set yet).  In that case, the
          # new phase thread will be still be started.
          if self._stopping.is_set():
            # PhaseRecord will be written at this point, so ensure that it has a
            # Killed result.
            result = PhaseExecutionOutcome(threads.ThreadTerminationError())
            phase_state.result = result
            return result
          phase_thread = PhaseExecutorThread(phase_desc, self.test_state)
          phase_thread.start()
          self._current_phase_thread = phase_thread
  
        phase_state.result = phase_thread.join_or_die()
        if phase_state.result.is_repeat and is_last_repeat:
          _LOG.error('Phase returned REPEAT, exceeding repeat_limit.')
          phase_state.hit_repeat_limit = True
          override_result = PhaseExecutionOutcome(openhtf.PhaseResult.STOP)
        self._current_phase_thread = None
  
      # Refresh the result in case a validation for a partially set measurement
      # raised an exception.
      result = override_result or phase_state.result
      _LOG.debug('Phase %s finished with result %s', phase_desc.name,
                 result.phase_result)
      return result
docs: Executes the given phase, returning a PhaseExecutionOutcome.