Skip to content

Commit

Permalink
task_count check in quota removal
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed Sep 12, 2023
1 parent b1fd36d commit 8059900
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions worker/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit 8059900

Please sign in to comment.