From: Michael Tremer Date: Fri, 27 May 2022 10:17:19 +0000 (+0000) Subject: daemon: Make workers async X-Git-Tag: 0.9.28~726 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49841f068e23937b97b8bd6cd1379422c5615b7d;p=pakfire.git daemon: Make workers async Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/daemon.py b/src/pakfire/daemon.py index 118151434..d75769dec 100644 --- a/src/pakfire/daemon.py +++ b/src/pakfire/daemon.py @@ -216,6 +216,15 @@ class Worker(multiprocessing.Process): # Register signal handlers self.register_signal_handlers() + # Run everything from here asynchronously + asyncio.run(self._work()) + + self.log.debug("Worker %s terminated gracefully" % self.pid) + + async def _work(self): + """ + Called from the async IO loop doing all the work + """ # Extract the job id job_id = self.data.get("id") if not job_id: @@ -228,8 +237,6 @@ class Worker(multiprocessing.Process): import time time.sleep(10) - self.log.debug("Worker %s terminated gracefully" % self.pid) - def shutdown(self): self.__running = False