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

Celery periodic tasks are not running

Open Shailendranjain opened this issue 4 years ago • 14 comments

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:

  1. While running the code above, the task is not getting executed (every once in a minute)
  2. However the task is getting saved in django_celery_beat models
  3. 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.

Shailendranjain avatar Mar 31 '20 02:03 Shailendranjain

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.

Shailendranjain avatar Mar 31 '20 15:03 Shailendranjain

I am facing same issue. Did you get any solution @Shailendranjain ? Thanks in advance.

sourabhvarshney111 avatar May 12 '20 04:05 sourabhvarshney111

isn't there any solution to this problem yet? I've tried ClockedTime and CronSchedule but nothing works.

tayyab-razzaq avatar Jun 15 '20 11:06 tayyab-razzaq

Same problem. Is there a solution?

obnormal avatar Oct 21 '20 07:10 obnormal

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.

daniellin215 avatar Dec 10 '20 01:12 daniellin215

I have the same problem, does anyone have any solutions?

luizmurilo97 avatar May 01 '21 18:05 luizmurilo97

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. image

gcdsss avatar May 06 '21 12:05 gcdsss

I was having the same issue. Updating celery beat to 2.2.1 solved this issue.

ashishgambhir24 avatar Jul 06 '21 05:07 ashishgambhir24

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. image

What do u mean by clean here?

somitmittal avatar Oct 28 '21 09:10 somitmittal

set to null

gcdsss avatar Oct 28 '21 09:10 gcdsss

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?

somitmittal avatar Oct 28 '21 09:10 somitmittal

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 ?

AditSoni avatar Jul 04 '22 11:07 AditSoni

Same here, I think this issue should be re-opened.

aaronn avatar Sep 22 '22 19:09 aaronn

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

edserrano419 avatar Nov 03 '22 14:11 edserrano419