buildroot: rename stage_timeout to timeout

The build root does not know anything about stages; the stage
concept is one level higher. Therefore rename `stage_timeout`
to `timeout` in the buildroot.
This commit is contained in:
Christian Kellner 2021-12-06 15:56:50 +00:00 committed by mergify[bot]
parent daf578b2f1
commit c434d7bea2
2 changed files with 7 additions and 7 deletions

View file

@ -168,7 +168,7 @@ class BuildRoot(contextlib.AbstractContextManager):
if self._exitstack:
self._exitstack.enter_context(api)
def run(self, argv, monitor, stage_timeout=None, binds=None, readonly_binds=None):
def run(self, argv, monitor, timeout=None, binds=None, readonly_binds=None):
"""Runs a command in the buildroot.
Takes the command and arguments, as well as bind mounts to mirror
@ -288,7 +288,7 @@ class BuildRoot(contextlib.AbstractContextManager):
poller = select.poll()
poller.register(proc.stdout.fileno(), READ_ONLY)
while True:
buf = self.read_with_timeout(proc, poller, start, stage_timeout)
buf = self.read_with_timeout(proc, poller, start, timeout)
if not buf:
break
@ -307,13 +307,13 @@ class BuildRoot(contextlib.AbstractContextManager):
return CompletedBuild(proc, output)
@classmethod
def read_with_timeout(cls, proc, poller, start, stage_timeout):
def read_with_timeout(cls, proc, poller, start, timeout):
fd = proc.stdout.fileno()
if stage_timeout is None:
if timeout is None:
return os.read(fd, 32768)
# convert stage_timeout to milliseconds
remaining = (stage_timeout * 1000) - (time.monotonic() - start)
# convert timeout to milliseconds
remaining = (timeout * 1000) - (time.monotonic() - start)
if remaining <= 0:
proc.terminate()
raise TimeoutError

View file

@ -195,7 +195,7 @@ class Stage:
r = build_root.run([f"/run/osbuild/bin/{self.name}"],
monitor,
stage_timeout=stage_timeout,
timeout=stage_timeout,
binds=binds,
readonly_binds=ro_binds)