From 822c18d9c29a42aaebd48341c6eca21abc71439e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 23 Oct 2022 17:57:10 +0000 Subject: [PATCH] daemon: Upload the log after the build has finished Signed-off-by: Michael Tremer --- src/pakfire/daemon.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pakfire/daemon.py b/src/pakfire/daemon.py index a6bb9ff47..c78e44401 100644 --- a/src/pakfire/daemon.py +++ b/src/pakfire/daemon.py @@ -247,12 +247,20 @@ class Worker(multiprocessing.Process): await self.job.status("building") # Run the build - build = self._build(pkg, arch=arch, - logger=logger._log, build_id=job_id) + try: + build = self._build(pkg, arch=arch, + logger=logger._log, build_id=job_id) + + # Wait until the build process is done and stream the log in the meantime + while not build.done(): + await logger.stream(timeout=1) - # Wait until the build process is done and stream the log in the meantime - while not build.done(): - await logger.stream(timeout=1) + finally: + # Upload the build log + log_upload_id = await self.hub.upload( + logger.logfile.name, + filename="%s.log" % job_id, + ) def _build(self, pkg, arch=None, logger=None, **kwargs): """ @@ -327,7 +335,7 @@ class BuildLogger(object): self.job = job # Create a logfile - self.logfile = tempfile.SpooledTemporaryFile(mode="w+", max_size=1048576) + self.logfile = tempfile.NamedTemporaryFile() # Create a FIFO queue to buffer any log messages self.queue = asyncio.Queue() -- 2.39.5