mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-05 22:28:12 +08:00
+4
-2
@@ -476,8 +476,10 @@ def save_task(task, broker: Broker):
|
|||||||
# SAVE LIMIT > 0: Prune database, SAVE_LIMIT 0: No pruning
|
# SAVE LIMIT > 0: Prune database, SAVE_LIMIT 0: No pruning
|
||||||
close_old_django_connections()
|
close_old_django_connections()
|
||||||
try:
|
try:
|
||||||
if task["success"] and 0 < Conf.SAVE_LIMIT <= Success.objects.count():
|
with db.transaction.atomic():
|
||||||
Success.objects.last().delete()
|
last = Success.objects.select_for_update().last()
|
||||||
|
if task["success"] and 0 < Conf.SAVE_LIMIT <= Success.objects.count():
|
||||||
|
last.delete()
|
||||||
# check if this task has previous results
|
# check if this task has previous results
|
||||||
if Task.objects.filter(id=task["id"], name=task["name"]).exists():
|
if Task.objects.filter(id=task["id"], name=task["name"]).exists():
|
||||||
existing_task = Task.objects.get(id=task["id"], name=task["name"])
|
existing_task = Task.objects.get(id=task["id"], name=task["name"])
|
||||||
|
|||||||
Reference in New Issue
Block a user