From 58fe8914cfd5a0dfca76e92bde4e638b1ff827c2 Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO <yohann.danello@gmail.com>
Date: Sun, 2 Aug 2020 22:39:30 +0200
Subject: [PATCH] :bug: Fix infinite loop in permission check

---
 apps/permission/models.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/apps/permission/models.py b/apps/permission/models.py
index d2ac2195..bf7dabfa 100644
--- a/apps/permission/models.py
+++ b/apps/permission/models.py
@@ -45,12 +45,11 @@ class InstancedPermission:
                 else:
                     oldpk = obj.pk
                 # Ensure previous models are deleted
-                count = 0
-                while count < 1000:
+                for ignored in range(1000):
                     if self.model.model_class().objects.filter(pk=obj.pk).exists():
                         # If the object exists, that means that one permission is currently checked.
                         # We wait before the other permission, at most 1 second.
-                        sleep(1)
+                        sleep(0.001)
                         continue
                     break
                 for o in self.model.model_class().objects.filter(pk=obj.pk).all():
-- 
GitLab