Exemple #1
0
    def wait_job_completion(self, **kwargs):
        interval = kwargs.pop('interval', 5)
        timeout = kwargs.pop('timeout', 3600)

        @retryz.retry(timeout=timeout, wait=interval, on_return=False)
        def _do_update():
            self.update()
            return self.check_errors()

        try:
            _do_update()
        except retryz.RetryTimeoutError:
            raise ex.JobTimeoutException()
Exemple #2
0
def wait_job_completion(job, **kwargs):
    interval = kwargs.pop('interval', 5)
    timeout = kwargs.pop('timeout', 3600)

    @retryz.retry(timeout=timeout, wait=interval, on_return=False)
    def _do_update():
        job.update()
        if job.state == enums.JobStateEnum.COMPLETED:
            return True
        elif job.state in (enums.JobStateEnum.FAILED,
                           enums.JobStateEnum.ROLLING_BACK,
                           enums.JobStateEnum.COMPLETED_WITH_ERROR):
            raise ex.JobStateError(job)
        return False

    try:
        _do_update()
    except retryz.RetryTimeoutError:
        raise ex.JobTimeoutException()