From dc2aaeec4173f0c8ed5d6df73af08a9ac1565d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 7 May 2026 18:12:20 +0200 Subject: [PATCH] Delegate notification handling of worker to the backend Since bb52a833e823 the backend provides methods to handle notification. Closes #14821 (grafted from 2763a98a25e401887fb9ac5049ce21d97b622f66) --HG-- branch : 8.0 --- trytond/trytond/worker.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/trytond/trytond/worker.py b/trytond/trytond/worker.py index fd45aad2c3..c881e5865d 100644 --- a/trytond/trytond/worker.py +++ b/trytond/trytond/worker.py @@ -40,6 +40,9 @@ class Queue(object): def run(self, task_id): return self.executor.submit(run_task, self.database.name, task_id) + def get_notifications(self): + return self.database.get_notifications(self.connection) + class TaskList(list): def filter(self): @@ -79,7 +82,8 @@ def work(options): tasks = TaskList() for queue in queues: - selector.register(queue.connection, selectors.EVENT_READ) + selector.register( + queue.connection, selectors.EVENT_READ, data=queue) while True: timeout = options.timeout @@ -104,10 +108,8 @@ def work(options): break else: for key, _ in selector.select(timeout=timeout): - connection = key.fileobj - connection.poll() - while connection.notifies: - connection.notifies.pop(0) + queue = key.data + queue.get_notifications() def initializer(database_names, worker=True):