From b3b49f3379c82ae1b11e8a51802612edd70f2dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 8 Dec 2022 13:34:01 +0100 Subject: [PATCH] Reset timeout loop of worker on each iteration If there was a next task planned very soon, this should not become the default timeout for future loop. issue11913 review415971003 (grafted from 10426538d63f736318c9eb5028cf34d423701422) --HG-- branch : 6.0 --- trytond/trytond/worker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trytond/trytond/worker.py b/trytond/trytond/worker.py index d9777c53b9..b1ed119c47 100644 --- a/trytond/trytond/worker.py +++ b/trytond/trytond/worker.py @@ -62,15 +62,15 @@ def work(options): queues = [Queue(name, mpool) for name in options.database_names] tasks = TaskList() - timeout = options.timeout try: while True: + timeout = options.timeout while len(tasks.filter()) >= processes: time.sleep(0.1) for queue in queues: task_id, next_ = queue.pull(options.name) - timeout = min( - next_ or options.timeout, timeout, options.timeout) + if next_ is not None: + timeout = min(next_, timeout) if task_id: tasks.append(queue.run(task_id)) break