From 2da43112879490ee149cb88989d5db34dd2f6188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 23 Dec 2022 19:44:09 +0100 Subject: [PATCH] Add some randomness to avoid concurrent pulling of new tasks This prevents multiple workers to pull the same new task at the same time which can create concurrency conflict. Closes #11938 --- trytond/trytond/worker.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/trytond/trytond/worker.py b/trytond/trytond/worker.py index 2a67425610..ede6fd9ab5 100644 --- a/trytond/trytond/worker.py +++ b/trytond/trytond/worker.py @@ -70,6 +70,8 @@ def work(options): try: while True: timeout = options.timeout + # Add some randomness to avoid concurrent pulling + time.sleep(0.1 * random.random()) while len(tasks.filter()) >= processes: time.sleep(0.1) for queue in queues: