From c434d7bea2561bc3c03d89440f4a3e8713a7d618 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Mon, 6 Dec 2021 15:56:50 +0000 Subject: [PATCH] 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. --- osbuild/buildroot.py | 12 ++++++------ osbuild/pipeline.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osbuild/buildroot.py b/osbuild/buildroot.py index 4a8646d4..0ae95220 100644 --- a/osbuild/buildroot.py +++ b/osbuild/buildroot.py @@ -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 diff --git a/osbuild/pipeline.py b/osbuild/pipeline.py index 25cbc693..75561df3 100644 --- a/osbuild/pipeline.py +++ b/osbuild/pipeline.py @@ -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)