Django-celery-beat: Beat crazely keeps sending tasks every millisecond

Created on 22 Dec 2017  路  8Comments  路  Source: celery/django-celery-beat

Using latest version as of current date.

Every thing is setup quite well. The only thing which is not going according to plan is the sending of periodic tasks by beat.

When I schedule a task in django admin panel, and then enable it, it does not go according to the plan.

Here is what happens,

[2017-12-22 20:07:46,076: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->bdb547f4-9a5c-4208-a976-08f297b16db9
[2017-12-22 20:07:46,078: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,079: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->cd24ccdd-cec8-459d-98a2-e69e68520e6a
[2017-12-22 20:07:46,082: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,084: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->de678d9a-9346-48a5-9528-e4ed61763bff
[2017-12-22 20:07:46,086: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,087: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->f07bee5e-

6cc1-40a6-9036-f66328a50012
[2017-12-22 20:07:46,090: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,091: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->9c996e9d-27c0-4c29-83e4-efc5fb78b633
[2017-12-22 20:07:46,093: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,095: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->e7babf88-801d-422e-90cf-aa4d5bacf58f
[2017-12-22 20:07:46,097: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,098: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->b1f0ff65-fe51-4729-ab5c-a33d6c749906
[2017-12-22 20:07:46,100: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,102: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->e7b4d598-7476-4938-8763-bc8aec38964f
[2017-12-22 20:07:46,104: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,106: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->13957883-165e-45d2-9a90-be4f85240088
[2017-12-22 20:07:46,108: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,109: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->6854029f-3323-4436-b7d9-8e584283d11f
[2017-12-22 20:07:46,111: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,113: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->b1f87ad8-e307-4e8d-92b3-4074ee6f5a62
[2017-12-22 20:07:46,115: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,116: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->a69ede44-4a40-4779-be4f-a125eadfbe20
[2017-12-22 20:07:46,118: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,120: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->7bdd092e-28fb-4e4e-a39d-f0608aab0d20
[2017-12-22 20:07:46,122: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,127: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->0055b837-c0a5-4304-b74e-5cb996395c14
[2017-12-22 20:07:46,131: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,139: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->bbae06cf-0ece-4663-9f05-7de416405da2
[2017-12-22 20:07:46,146: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,153: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->f648893b-fee1-4ba5-abca-ac8a4d68ba6a
[2017-12-22 20:07:46,156: INFO/MainProcess] Scheduler: Sending due task Send daily report of Oil Changes (db.tasks.send_daily_report)
[2017-12-22 20:07:46,162: DEBUG/MainProcess] db.tasks.send_daily_report sent. id->65589480-e021-4ca5-b865-d55729e195f0

But my schedule in crontab is 15 * * * *. So, it means it is not going according to the schedule,

What is wrong here? Why is it not reading my interval?

Most helpful comment

should we update docs? and close this issue?

another bug happened, schedule tasks run 8 hours earlier caused by app.now = timezone.now

All 8 comments

This issue probably is a duplicate of #95.

Don't use special timezone work ok.
config like this:

timezone = 'UTC'
enable_utc = True

I have the same problem when I specify the timezone and set USE_TZ = False.

It will work well when USE_TZ = True.

I found the hacking settings like this:

DJANGO_CELERY_BEAT_TZ_AWARE = False
app.now = timezone.now

example:

settings.py

# IMPORTANT: fix django-celery-beat with `USE_TZ = False`, interval tasks be called continuously
# time zone native
DJANGO_CELERY_BEAT_TZ_AWARE = False

celery.py

from __future__ import absolute_import, unicode_literals

import os

from celery import Celery
from django.utils import timezone

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PROJECT_NAME.settings')

app = Celery('PROJECT_NAME')

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')

# IMPORTANT: fix django-celery-beat with `USE_TZ = False`, interval tasks be called continuously
app.now = timezone.now

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()

I hope this will help someone else.

should we update docs? and close this issue?

should we update docs? and close this issue?

another bug happened, schedule tasks run 8 hours earlier caused by app.now = timezone.now

with celery 4.3/master and all dependencies of celery from masters still, reproduce this?

Purge celery queue after you change config.It works for me.

Was this page helpful?
0 / 5 - 0 ratings