3

I'm using django-celery-beat https://django-celery-beat.readthedocs.io/en/latest/ to manage celery tasks in my django project.


Code Snippets:

creating Interval time

def get_or_create_interval(interval_time):
    schedule,created = IntervalSchedule.objects.get_or_create( 
        every=interval_time,
        period=IntervalSchedule.HOURS,
    )
    return schedule

creating a periodic task based on above interval time:

def set_periodic_task(project_name,task_name,project_id):
    interval = get_or_create_interval(25)
    PeriodicTask.objects.create(
        interval=interval,
        name='{0}-{1}'.format(project_name,project_id),
        task=task_name, 
        kwargs=json.dumps({'project_id': 35,
        }),
    )

I have created some periodic tasks with different interval times and noticed that tasks which are under 24 hours of interval times get executed only.

Highlighted tasks which don't executes.

enter image description here

Please let me know what could be the possible reasons for this behaviour.

settings.py

######## CELERY : CONFIG
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = "Asia/Kolkata"
CELERYBEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler'
### ThirdPartyTOols
→ pip3 list | grep "celery"
celery (4.2.1)
django-celery (3.2.2)
django-celery-beat (1.3.0)

Thank you.

Arbazz Hussain
  • 1,622
  • 2
  • 15
  • 41

0 Answers0