From 8059900a58b57599221b913ad355a932a3b2e602 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Tue, 12 Sep 2023 12:40:45 -0400 Subject: [PATCH] task_count check in quota removal --- worker/tasks.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/worker/tasks.py b/worker/tasks.py index 3cafcdbd..ca290e13 100644 --- a/worker/tasks.py +++ b/worker/tasks.py @@ -217,6 +217,8 @@ def check_quotas(): if now > deadline: # deadline passed, delete tasks until quota is met logger.info("Quota deadline expired for %s, deleting tasks" % str(p.user.username)) + task_count = Task.objects.filter(project__owner=p.user).count() + c = 0 while p.has_exceeded_quota(): try: @@ -227,6 +229,9 @@ def check_quotas(): last_task.delete() except Exception as e: logger.warn("Cannot delete %s for %s: %s" % (str(last_task), str(p.user.username), str(e))) + + c += 1 + if c >= task_count: break else: p.clear_quota_deadline()