2

I trying to send scheduled emails to users but my Django celery periodic tasks running 2 times within a half-hour span. Every day I scheduled my email task at 7.00 AM but it is running 1st task at 7.00 AM and the same task is running at 7.30 AM also.

Here is my celery app

# coding=utf-8
from __future__ import absolute_import

import os

from celery import Celery
from django.conf import settings


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app_name.settings")

app = Celery("app_name")

app.config_from_object("app_name.celeryconfig")
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

@app.task(bind=True)
def debug_task(self):
    print ("Request: {0!r}".format(self.request))

Celery app config

# coding=utf-8
import os


PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))

# Celery Config
BROKER_URL = 'redis://redis_server:6379'
CELERY_RESULT_BACKEND = 'redis://redis_server:6379'

CELERY_TASK_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['application/json']  # Ignore other content
CELERY_RESULT_SERIALIZER = 'json'

CELERY_ENABLE_UTC = True


CELERY_TASK_RESULT_EXPIRES = 0  # Never expire task results
CELERY_IGNORE_RESULT = True

CELERY_TRACK_STARTED = True


CELERY_IMPORTS = (
    "module.tasks"
)

Periodic Tasks scheduled in Django admin panel enter image description here

To run the celery app and celery beat I used following command

celery -A app_name worker -l INFO

celery -A app_name beat --loglevel=debug --scheduler django_celery_beat.schedulers:DatabaseScheduler --pidfile=

Functionality working fine but these tasks are running twice daily for 2 to 3 days after that, it will run once but if I restart celery then It will start running tasks again twice for some days.

Please let me know If I'm missing in celery configuration.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.