celery / django-celery-beat

Celery Periodic Tasks backed by the Django ORM
Other
1.69k stars 429 forks source link

celery beat total_run_count is not updating. #674

Open Erkaboy0313 opened 1 year ago

Erkaboy0313 commented 1 year ago

Summary: I have created a Periodic task like this.

PeriodicTask.objects.create(name = 'taskname', interval = interval, task = 'taskName', args = json.dumps([data1,data2])

It should call a task every 10 seconds. If the task runs successfully it should stop, if it isn't successful even after 10 times I should send a fail message and stop the task. In order to keep track of this I tried total_run_count. But It does not show the exact number of counts every time. For example, total_run_count returns 0, 13 times, and returns 14 at the 14th time. I'm checking total_run_count in my task like this:

task = PeriodicTask.objects.get(name = order)
if task.total_run_count >= 10:
    task.enabled = False
    task.save()
    ....

I might done something wrong or It isn't good practice.

Include a brief description of the problem here, and fill out the version info below.

Exact steps to reproduce the issue:

Detailed information

Please include more detailed information here, such as relevant information about your system setup, things you did to try and debug the problem, log messages, etc.

AryanHamedani commented 8 months ago

I have the same problem, I'ts partially being updated ( for some of the tasks it's updated but for most of them its not )

cclauss commented 8 months ago

Is this issue fixed in release v2.6.0?

ZipBrandon commented 7 months ago

I'm on v2.6.0 and I'm seeing inconsistent reflection in the last run time on a 1 minute interval. I see the task running in my worker but the last run time isn't always accurately reflected in the Django Admin. I bet my issue is related to the root cause of this.