django-celery-beat
django-celery-beat copied to clipboard
Celery periodic tasks are not running
Summary:
Here is a code example
proj/_celery.py
os.environ.setdefault('DJANGO_SETTINGS_MODULE','proj.settings') app = Celery('proj') app.config_from_object('django.conf.settings') app.autodiscover_tasks(settings.INSTALLED_APPS)
proj/tools/tasks.py
from celery.decorators import task from celery.utils.log import get_task_logger logger = get_task_logger('ids')
@task(name='send_feedback_email_task') def send_feedback_email_task(): logger.info("Test")
proj/tools/views/some_view.py
from django_celery_beat.models import CrontabSchedule, PeriodicTask
Class SomeView(CreateView)
def form_valid(self, form): schedule = CrontabSchedule.objects.get_or_create(minute='*/1') task = PeriodTask.objects.create(name='feedback_email', task='proj.tools.tasks import send_feedback_email_task', crontab=schedule) return HttpResponseRedirect(self.get_success_url())
Include a brief description of the problem here, and fill out the version info below.
- Celery Version: 4.2.1
- Celery-Beat Version: 1.1.1
Exact steps to reproduce the issue:
- While running the code above, the task is not getting executed (every once in a minute)
- However the task is getting saved in django_celery_beat models
- Can you please advise why the task is not getting executed.
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.
The celery beat log shows the current schedule as below
<ModelEntry: taskname proj.tools.task.send_feedback_email_task(*[], **{}) <crontab: */1 * * * * (m/h/d/dM/MY)>> Beat: waking up in 5.00 seconds
Looks like it is not sending task when it is due.
I am facing same issue. Did you get any solution @Shailendranjain ? Thanks in advance.
isn't there any solution to this problem yet? I've tried ClockedTime and CronSchedule but nothing works.
Same problem. Is there a solution?
I have the same issue, where all I see is Beat: waking up in 5.00 seconds
repeating itself indefinetly (debug logging mode)
I am running the celery-beat, celery and django all in a docker compose environment. The celery worker is picking up the tasks from my django app properly but the celery-beat isn't sending any tasks, it is just repeating the wake up sequence mentioned above.
I have the same problem, does anyone have any solutions?
I did have the same issues with periodictask,
but I solved by clean up the start_time field in django_celery_beat_periodictask model, this issued must be related to TZ settings, the timezone setting caused it.
Take a look at your periodictask in sql and clean up this field, works for me.
PS. I just tried with periodictask, and it's fine, not sure if works for the other task type.
I was having the same issue. Updating celery beat to 2.2.1 solved this issue.
I did have the same issues with periodictask, but I solved by clean up the start_time field in django_celery_beat_periodictask model, this issued must be related to TZ settings, the timezone setting caused it. Take a look at your periodictask in sql and clean up this field, works for me. PS. I just tried with periodictask, and it's fine, not sure if works for the other task type.
What do u mean by clean here?
set to null
set to null
Okay in my case its already set to NULL but main problem i am facing is that periodic tasks stop working midway. Happened couple of times. Do you have any workaround for this?
having the same issue , tasks were present in periodic task table but were not sent to celery workers also i had disabled the celery cleanup task , can it be a reason for tasks not being sent to workers ?
Same here, I think this issue should be re-opened.
Tested PeriodicTasks(crontab/interval) working with this combo celery-5.2.7 django-celery-beat-2.4.0 django-timezone-field-5.0 kombu-5.2.4 using UTC