Condition check on finished or stopped status

        The method returns a value which is equivalent with not 'active' status of the current state machine.

        :return: outcome of condition check stopped or finished
        :rtype: bool
7449
def finished_or_stopped(self):
        
        return (self._status.execution_mode is StateMachineExecutionStatus.STOPPED) or \
               (self._status.execution_mode is StateMachineExecutionStatus.FINISHED)
1134412
def check_pause(self):
        

        # todo task_runner vs model

        pause_time = 0.0
        sleep_time = 0.1
        if self.model.tasks_paused:
            while self.model.tasks_paused:
                sleep(pause_time)
                pause_time += sleep_time
        return pause_time
520807
def is_terminated(self, retry=False):
        
        retry_num = options.retry_times
        while retry_num > 0:
            try:
                return self.status == Instance.Status.TERMINATED
            except (errors.InternalServerError, errors.RequestTimeTooSkewed):
                retry_num -= 1
                if not retry or retry_num <= 0:
                    raise
563547
def wait_for_state_machine_finished(state_machine):
    
    global _user_abort

    from rafcon.core.states.execution_state import ExecutionState
    if not isinstance(state_machine.root_state, ExecutionState):
        while len(state_machine.execution_histories[0]) < 1:
            time.sleep(0.1)
    else:
        time.sleep(0.5)

    while state_machine.root_state.state_execution_status is not StateExecutionStatus.INACTIVE:
        try:
            state_machine.root_state.concurrency_queue.get(timeout=1)
            # this check triggers if the state machine could not be stopped in the signal handler
            if _user_abort:
                return
        except Empty:
            pass
        # no logger output here to make it easier for the parser
        logger.verbose("RAFCON live signal")
727861
def status(self):
        
        myNow = timezone.localtime(timezone=self.tz)
        daysDelta = dt.timedelta(days=self.num_days - 1)
        # NB: postponements can be created after the until date
        #     so ignore that
        todayStart = getAwareDatetime(myNow.date(), dt.time.min, self.tz)
        eventStart, event = self.__afterOrPostponedTo(todayStart - daysDelta)
        if eventStart is None:
            return "finished"
        eventFinish = getAwareDatetime(eventStart.date() + daysDelta,
                                       event.time_to, self.tz)
        if event.time_from is None:
            eventStart += _1day
        if eventStart < myNow < eventFinish:
            # if there are two occurences on the same day then we may miss
            # that one of them has started
            return "started"
        if (self.repeat.until and eventFinish < myNow and
            self.__afterOrPostponedTo(myNow)[0] is None):
            # only just wound up, the last occurence was earlier today
            return "finished"
885842
def status(self):
        
        message = self.end_message if self.end_message else self.start_message
        if message:
            return message.contents[ACTION_STATUS_FIELD]
        else:
            return None
737995
def done(self):
        
        if self._done:
            return self._done

        if self._limit is None:
            self._done = False
        elif self.itemcount >= self._limit:
            self._done = True

        return self._done
522463
def is_done(self):
        

        return (not self.wait_for_output or self.eof) and \
                not (hasattr(self.to_stream, 'needs_write') and self.to_stream.needs_write())
727933
def is_running(self):
        
        try:
            return graceful_get(self.inspect(refresh=True), "State", "Running")
        except subprocess.CalledProcessError:
            return False
82729
def task_done(self, **kw):
        
        def validate(task):
            if not Status.is_pending(task['status']):
                raise ValueError("Task is not pending.")

        return self._task_change_status(Status.COMPLETED, validate, **kw)
402090
def _is_finished(self, as_of):
        
        if self.is_one_off():
            last_billing_cycle = self.get_billing_cycles()[self.total_billing_cycles - 1]
            return last_billing_cycle.date_range.upper <= as_of
        else:
            return False
592530
public boolean isCompleted() {
    WorkingState state = getWorkingState();
    return state == WorkingState.SUCCESSFUL || state == WorkingState.COMMITTED || state == WorkingState.FAILED;
  }
835246
def finalize_concurrency_state(self, outcome):
        
        final_outcome = outcome
        self.write_output_data()
        self.check_output_data_type()
        self.execution_history.push_return_history_item(self, CallType.CONTAINER, self, self.output_data)
        self.state_execution_status = StateExecutionStatus.WAIT_FOR_NEXT_STATE

        singleton.state_machine_execution_engine._modify_run_to_states(self)

        if self.preempted:
            final_outcome = Outcome(-2, "preempted")
        return self.finalize(final_outcome)
255282
def check_complete(self):
        
        logger.debug('Running check_complete for task {0}'.format(self.name))

        # Tasks not completed
        if self.remote_not_complete() or self.local_not_complete():
            self._start_check_timer()
            return

        return_code = self.completed_task()

        # Handle task errors
        if self.terminate_sent:
            self.stderr += '\nDAGOBAH SENT SIGTERM TO THIS PROCESS\n'
        if self.kill_sent:
            self.stderr += '\nDAGOBAH SENT SIGKILL TO THIS PROCESS\n'
        if self.remote_failure:
            return_code = -1
            self.stderr += '\nAn error occurred with the remote machine.\n'

        self.stdout_file = None
        self.stderr_file = None

        self._task_complete(success=True if return_code == 0 else False,
                            return_code=return_code,
                            stdout=self.stdout,
                            stderr=self.stderr,
                            start_time=self.started_at,
                            complete_time=datetime.utcnow())
41959
def complete(self):
        
        return self.valid and (self.access_token or self.refresh_token or self.type == 2)
431649
def done(self, retry=DEFAULT_RETRY):
        
        # Do not refresh is the state is already done, as the job will not
        # change once complete.
        if self.state != _DONE_STATE:
            self.reload(retry=retry)
        return self.state == _DONE_STATE
53681
def evaluate_stop_condition(errdata, stop_condition):
    
    if stop_condition:
        return_code = stop_condition(list(errdata))
        if return_code != -1:
            log.info(
                'Stop condition triggered!  Relay is terminating.',
                extra=dict(return_code=return_code))
            sys.exit(return_code)