Background task running twice.
I am using django-background tasks to process file- extract data and perform some activity and save the data to db. When ever I upload a file, the job is getting executed twice and the records are getting duplicated. Sometimes, there is no response at all.
I am using subprocess popen to initiate the tasks when ever file is uploaded. Not able to understand if this is the reason for the multiple runs..
Also I have added the below options in settings BACKGROUND_TASK_RUN_ASYNC = False MAX_ATTEMPTS = 2
process_tasks_cmd = "python manage.py process_tasks --duration 0" subprocess.Popen(process_tasks_cmd, shell=True)
I found somethings useful. To solve it by doing
from background_task.models import Task
Task.objects.all().delete()
I found somethings useful. To solve it by doing
from background_task.models import Task Task.objects.all().delete()
Lol.