]> git.ipfire.org Git - pakfire.git/commitdiff
daemon: Make job_id a property
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 26 May 2023 16:59:14 +0000 (16:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 26 May 2023 16:59:14 +0000 (16:59 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/daemon.py

index fadfa4bfc2ed18c887bb265ec49b2b9b8b1163fe..c3df4124e1a7874b7ab1a4f02496508066e8cccf 100644 (file)
@@ -214,6 +214,10 @@ class Worker(multiprocessing.Process):
                """
                return self.data.get("test", False)
 
+       @property
+       def job_id(self):
+               return self.data.get("id")
+
        @property
        def ccache(self):
                """
@@ -241,13 +245,12 @@ class Worker(multiprocessing.Process):
                """
                success = False
 
-               # Extract the job id
-               job_id = self.data.get("id")
-               if not job_id:
+               # Check if we have received some useful data
+               if not self.job_id:
                        raise ValueError("Did not receive a job ID")
 
                # Set the process title
-               setproctitle.setproctitle("pakfire-worker job %s" % job_id)
+               setproctitle.setproctitle("pakfire-worker job %s" % self.job_id)
 
                # Fetch the build architecture
                arch = self.data.get("arch")
@@ -262,7 +265,7 @@ class Worker(multiprocessing.Process):
                        raise ValueError("Did not received a package URL")
 
                # Connect to the hub
-               self.job = await self.hub.job(job_id, worker=self)
+               self.job = await self.hub.job(self.job_id, worker=self)
 
                # Setup build logger
                logger = BuildLogger(self.log, self.job)
@@ -274,7 +277,7 @@ class Worker(multiprocessing.Process):
                        # Run the build
                        try:
                                build = self._build(pkg, arch=arch, target=target,
-                                       logger=logger._log, build_id=job_id,
+                                       logger=logger._log, build_id=self.job_id,
 
                                        # Always disable using snapshots
                                        disable_snapshot=True,