Celery beat PeriodicTask max executions

Im trying to put max executions to my PeriodicTask with IntervalSchedule.

I know total_run_count but, ¿how can use it to put max executions to my PeriodicTask?

@receiver(post_save, sender=AutoTask)
def create_periodic_task(sender, instance, **kwargs):
   interval = IntervalSchedule.objects.get_or_create(every=instance.every, period=instance.periodicity)[0]
   PeriodicTask.objects.create(name=instance.title, task="create_autotask", start_time=instance.creation_date, total_run_count=instance.repetitions, interval=interval)

I coded this, but, in this case, I can configure the interval (example : each 2 days ), but... how can I limitate the repetitions?

Ty

Back to Top