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
This commit is contained in:
Cédric Krier committed 2022-12-23 19:47:47 +01:00
1 parent e76de7cb81
commit 83f516f4fe
1 file changed
+4 -1
+4 -1
View File
@@ -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: