[elbe-devel] [PATCH 2/2] elbepack: projectmanager: create one worker per project

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon Sep 9 14:17:33 CEST 2024


Each worker can only process one job at a time.
To enable work on multiple projects at once, create a worker for each
one.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/projectmanager.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index 64f56ce453ab..82b492130dfc 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -40,13 +40,18 @@ class ProjectManager:
     def __init__(self, basepath):
         self.basepath = basepath    # Base path for new projects
         self.db = ElbeDB()          # Database of projects and users
-        self.worker = AsyncWorker(self.db)
+        self._workers = {}
 
     def stop(self):
-        self.worker.stop()
+        for worker in self._workers.values():
+            worker.stop()
 
     def _enqueue(self, job):
-        self.worker.enqueue(job)
+        builddir = job.project.builddir
+        if builddir not in self._workers:
+            self._workers[builddir] = AsyncWorker(self.db)
+
+        self._workers[builddir].enqueue(job)
 
     def new_project(self, userid):
         subdir = str(uuid7())

-- 
2.46.0



More information about the elbe-devel mailing list