From 83f516f4fe4260cd6d83ccd8d5a631f987de0ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 23 Dec 2022 19:47:47 +0100 Subject: [PATCH] Retry pulling from the queue when DatabaseOperationalError is raised The Queue.pull method can raise such exception even with an autocommit transaction because the update query can be in conflict with another same update query. This is because we use repeatable isolation level. Closes #11937 --- trytond/trytond/worker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trytond/trytond/worker.py b/trytond/trytond/worker.py index ede6fd9ab5..546e607462 100644 --- a/trytond/trytond/worker.py +++ b/trytond/trytond/worker.py @@ -75,7 +75,10 @@ def work(options): while len(tasks.filter()) >= processes: time.sleep(0.1) for queue in queues: - task_id, next_ = queue.pull(options.name) + try: + task_id, next_ = queue.pull(options.name) + except backend.DatabaseOperationalError: + break if next_ is not None: timeout = min(next_, timeout) if task_id: