From: Michael Tremer Date: Sat, 29 Apr 2023 14:08:19 +0000 (+0000) Subject: jobs: Implement launch function that launches multiple jobs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a239d87c8b68735071346a77d62132f7f73f56c4;p=pbs.git jobs: Implement launch function that launches multiple jobs Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 9a5e058f..ea426900 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -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 diff --git a/src/scripts/pakfire-build-service b/src/scripts/pakfire-build-service index d0b4a189..e922fa60 100644 --- a/src/scripts/pakfire-build-service +++ b/src/scripts/pakfire-build-service @@ -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 diff --git a/src/web/builds.py b/src/web/builds.py index 0089988c..c5fc1466 100644 --- a/src/web/builds.py +++ b/src/web/builds.py @@ -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):