django-background-tasks icon indicating copy to clipboard operation
django-background-tasks copied to clipboard

Background task running twice.

Open saranmaikalluri opened this issue 3 years ago • 2 comments

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)

saranmaikalluri avatar Jun 06 '22 06:06 saranmaikalluri

I found somethings useful. To solve it by doing


from background_task.models import Task
Task.objects.all().delete()

quangtn-olli avatar Nov 24 '22 08:11 quangtn-olli

I found somethings useful. To solve it by doing


from background_task.models import Task
Task.objects.all().delete()

Lol.

philippeowagner avatar Nov 24 '22 08:11 philippeowagner