示例#1
0
    def block_until_complete(self, delay=15, timeout=None):
        """block until this build stop running.
        
        Args:
            delay: check status every `delay` seconds, default is 15s.
            timeout: wait `timeout` seconds at most, default is forever.

        Returns:
            True if stopped, False if still running.
        """
        if self.is_static:
            raise exception.ImappropriateMethodInStaticMode(
                "block_until_complete")

        stime = time.time()
        while self.is_running:
            waited = time.time() - stime
            logging.info("waited %is for %s to complete" % (waited, str(self)))
            if timeout is not None and timeout < waited:
                raise exception.RunTimeout("wait %is > %is, timeout!" %
                                           (waited, timeout))

            time.sleep(delay)

        # update info
        self.poll()
        return True
示例#2
0
    def block(self):
        """block until this build stop running.
        
        Do not use this method too often,
        because it will request jenkins server every second.
        """
        if self.is_static:
            raise exception.ImappropriateMethodInStaticMode("block")
        while self.is_running:
            time.sleep(1)

        # update info
        self.poll()
示例#3
0
文件: queue.py 项目: hustcsxg/UPL4CY
    def block_until_complete(self, delay=15, timeout=None):
        """block until task of this queue item build and complete."""
        if self.is_static:
            raise exception.ImappropriateMethodInStaticMode("block_until_complete")

        stime = time.time()
        build = self.block_until_building(delay)
        if timeout is not None:
            waited = time.time() - stime
            if timeout < waited:
                raise exception.RunTimeout("wait %is > %is, timeout!" % (waited, timeout))

            timeout -= waited
        return build.block_until_complete(delay=delay, timeout=timeout)
示例#4
0
文件: queue.py 项目: hustcsxg/UPL4CY
    def block_until_building(self, delay=15, timeout=None):
        """block until task of this queue item build."""
        if self.is_static:
            raise exception.ImappropriateMethodInStaticMode("block_until_building")

        stime = time.time()
        while True:
            try:
                self.poll()
                return self.build
            except exception.NotBuiltYet:
                pass

            waited = time.time() - stime
            if timeout is not None and timeout < waited:
                raise exception.RunTimeout("wait %is > %is, timeout!" % (waited, timeout))

            time.sleep(delay)