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
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)
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)