Пример #1
0
    def wait_for(self, wait_for):
        """
        Wait for callback to return True.

        Simply returns if wait_for condition has been met,
        raises TimeoutExpired otherwise and kills the process.

        :param callback wait_for: callback to call
        :raises: mirakuru.exceptions.TimeoutExpired
        """
        while self.check_timeout():
            if wait_for():
                return
            time.sleep(self._sleep)

        self.kill()
        raise TimeoutExpired(self, timeout=self._timeout)
Пример #2
0
    def wait_for(self: SimpleExecutorType,
                 wait_for: Callable[[], bool]) -> SimpleExecutorType:
        """
        Wait for callback to return True.

        Simply returns if wait_for condition has been met,
        raises TimeoutExpired otherwise and kills the process.

        :param callback wait_for: callback to call
        :raises: mirakuru.exceptions.TimeoutExpired
        :returns: itself
        :rtype: SimpleExecutor
        """
        while self.check_timeout():
            if wait_for():
                return self
            time.sleep(self._sleep)

        self.kill()
        raise TimeoutExpired(self, timeout=self._timeout)
Пример #3
0
    def wait_for(self, wait_for):
        while self.check_timeout():
            log.debug(
                "Executor process: waiting",
                command=self.command,
                until=self._endtime,
                now=time.time(),
            )
            if wait_for():
                log.debug(
                    "Executor process: waiting ended",
                    command=self.command,
                    until=self._endtime,
                    now=time.time(),
                )
                return self
            time.sleep(self._sleep)

        self.kill()
        raise TimeoutExpired(self, timeout=self._timeout)