From 0ebe6d8233fa39812b7a35aa2a29f9998ca157f6 Mon Sep 17 00:00:00 2001 From: Pierre Ducroquet Date: Wed, 22 Jun 2022 13:52:22 +0200 Subject: [PATCH] PaymentBackend: skip poll faster if there is no transaction (#66487) --- combo/apps/lingo/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 03318c81..c214f718 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -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():