def wait_for_next_tick_or_stop()

in codeguru_profiler_agent/utils/execution_state.py [0:0]


    def wait_for_next_tick_or_stop(self):
        """
        Wait until it is time to execute or the process is stopped.
        Status should either be RUNNING or STOPPED at the end.
        If initial_delay was set to 0 this will return True even if we
        have immediately paused or stopped.

        :return: True if the status is RUNNING at the end. False otherwise.
        """
        is_time_to_execute = False
        while self._current_state is not ExecutionState.STOPPED and not is_time_to_execute:
            self._time_when_waiting_started = self._clock()
            if self._current_state is ExecutionState.PAUSED:
                new_state = self._wait_for_resume()
            else:
                new_state = self._wait_for_execution_time()
            # update state, if there is no change in the state after waiting then it is time to execute.
            is_time_to_execute = not self._apply_new_state(new_state)
            if new_state:
                self._state_changes.task_done()

        # if we exit the while loop that means either we are stopped or it is time to execute
        # remove the initial_delay as we do not need it anymore, also reset _already_waited_seconds
        self.initial_delay = None
        self._already_waited_seconds = 0.0
        return self._current_state is ExecutionState.RUNNING