django-celery-beat icon indicating copy to clipboard operation
django-celery-beat copied to clipboard

celery beat total_run_count is not updating.

Open Erkaboy0313 opened this issue 1 year ago • 3 comments

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.

  • Celery Version: celery==5.3.1
  • Celery-Beat Version: django-celery-beat==2.5.0

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.

Erkaboy0313 avatar Aug 31 '23 18:08 Erkaboy0313

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 )

AryanHamedani avatar Feb 13 '24 14:02 AryanHamedani

Is this issue fixed in release v2.6.0?

cclauss avatar Mar 04 '24 08:03 cclauss

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.

ZipBrandon avatar Mar 08 '24 16:03 ZipBrandon