]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Implement launch function that launches multiple jobs
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 29 Apr 2023 14:08:19 +0000 (14:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 29 Apr 2023 15:06:20 +0000 (15:06 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/jobs.py
src/scripts/pakfire-build-service
src/web/builds.py

index 9a5e058fa774d2f3bc0139608eb5b232fea41500..ea42690091c517597208822648fb5852c3ef52c2 100644 (file)
@@ -96,17 +96,19 @@ class Jobs(base.Object):
 
                return list(jobs)
 
-       async def depcheck(self, jobs):
+       async def launch(self, *jobs):
                """
-                       Performs a dependency check on all given jobs concurrently
+                       Called to launch all given jobs
                """
-               if jobs:
-                       results = await asyncio.gather(*(job.depcheck() for job in jobs))
+               if not jobs:
+                       return
 
-                       # Try to dispatch any jobs afterwards
-                       if any(results):
-                               await self.backend.jobs.queue.dispatch()
+               # Perform dependency checks for all jobs
+               results = await asyncio.gather(*(job.depcheck() for job in jobs))
 
+               # Try to dispatch any jobs afterwards
+               if any(results):
+                       await self.backend.jobs.queue.dispatch()
 
 
 class Queue(base.Object):
@@ -594,8 +596,8 @@ class Job(base.DataObject):
                # Clone the job
                job = self.clone()
 
-               # Schedule a dependency check
-               self.backend.run_task(self.depcheck)
+               # Launch the newly created job
+               self.backend.run_task(self.backend.jobs.launch, job)
 
        # Log
 
index d0b4a1892f7f5e019ac65e40f262771b2b454592..e922fa60afc1b0112034e6ea63143ff421e7c80e 100644 (file)
@@ -97,7 +97,8 @@ class Cli(object):
                        jobs.append(job)
 
                # Run the checks
-               await self.backend.jobs.depcheck(jobs)
+               for job in jobs:
+                       await job.depcheck()
 
        def _list_repository(self, distro_name, repo_name, arch):
                # Get distribution
index 0089988c85f5c5322f50a1b954e65700dc31aa64..c5fc1466b05fe570b46009862caea7f9036ce292 100644 (file)
@@ -52,8 +52,8 @@ class APIv1IndexHandler(base.APIMixin, base.BaseHandler):
                        "name" : "%s" % build,
                })
 
-               # Run dependency check on all jobs (in the background)
-               self.backend.run_task(self.backend.jobs.depcheck, build.jobs)
+               # Launch all jobs (in the background)
+               self.backend.run_task(self.backend.jobs.launch, build.jobs)
 
 
 class IndexHandler(base.BaseHandler):