PaymentBackend: skip poll faster if there is no transaction (#66487)

This commit is contained in:
Pierre Ducroquet 2022-06-22 13:52:22 +02:00 committed by Frédéric Péters
parent 8492dc2403
commit 22daaad4ef
1 changed files with 3 additions and 0 deletions

View File

@ -257,6 +257,9 @@ class PaymentBackend(models.Model):
status__in=Transaction.RUNNING_STATUSES,
).order_by('pk')
last_pk = -1
# skip fast in order to save some resources on database
if not transactions.exists():
return
while True:
# lock each transaction before trying to poll it
with atomic():