You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Celery no longer honoring Django's TIME_ZONE setting #4006
For Django users the time zone specified in the TIME_ZONE setting will be used
This used to be true (checked in Celery 3.1.25) but is no longer the case in Celery 4.
I can send a patch but would like to know if the expected solution is to add back support for this, or to update the documentation to no longer indicate that this setting is read.
Checklist
I have included the output of celery -A proj report in the issue.
(if you are not able to do this, then at least specify the Celery
version affected).
Version 4.0.2 (latentcall)
I have verified that the issue exists against the master branch of Celery.
Steps to reproduce
Run Celery from a Django project that has the TIME_ZONE setting set, but which does not specify CELERY_TIMEZONE.
Expected behavior
The configured timezone (e.g. app.conf.timezone is the same as that in Django's TIME_ZONE setting).
I also ran into and noticed this. I reference this behavior on celery/django-celery-beat#57. I would like it fixed soas to make it easier to keep them in sync from the config file.
@georgepsarakis@auvipy
It's obvious this should not have been closed. This is a bug that runs counter to the documentation.
I'm running celery==4.1.0 and Django==1.11.6.
Regardless of what I set for CELERY_TIMEZONE and TIMEZONE, Celery beat uses UTC. No combination of True and False for CELERY_ENABLE_UTC and USE_TZ makes a difference.
Reacted by Aliaksei Urbanski and Klaas van Schelven
@kylebebak thanks for reporting back. There have been some Celery Beat & timezone fixes in the latest release (4.2.0rc3), is it possible that you can try with that?
@georgepsarakis Thank you for the quick reply. I'll try with 4.2.0rc3 and let you know if that solves the problem, but I probably won't get around to it for a week or so.
I'm in a time zone that's between 5 and 6 hours behind UTC depending on DST, so for the time being I just added 5.5 hours to to all of my crontab Celery beat tasks.
I just stumbled in here after upgrading from 3.1.25 to 4.x. My periodic tasks are no longer honoring Django's timezone settings just as described by izquierdo.
Django version: 1.11.3
Celery version: tried on 4.0.0 and 4.4.0
Relevant Django settings:
USE_TZ = True
TIME_ZONE = 'America/Los_Angeles'
app.conf.timezone returns None and my periodic tasks fire on UTC time.
Setting the celery timezone setting (namespaced as CELERY_TIMEZONE for my install) results in app.conf.timezone having a value.
Celery recommends and is compatible with the new USE_TZ setting introduced in Django 1.4.
For Django users the time zone specified in the TIME_ZONE setting will be used, or you can specify a custom time zone for Celery alone by using the timezone setting.
AFAICS this problem still exists. Running celery v5.2.7, django 3.2.11.
settings.py:
TIME_ZONE = 'CET'
CELERY_BEAT_SCHEDULE = {
'debug_task': {
'task': 'project.celery.debug_task', # this is the thing from the tutorial
'schedule': crontab(minute="14", hour="11") # or whatever is right about to come up
},
}
# CELERY_TIMEZONE = TIME_ZONE # when this is turned on everything works as documented
It appears that app.conf.timezone is simply None.
Searching the code (case insensitive) for time_zone reveals only 1 location:
Activity
RabidCicada commentedon Jul 7, 2017
I also ran into and noticed this. I reference this behavior on celery/django-celery-beat#57. I would like it fixed soas to make it easier to keep them in sync from the config file.
georgepsarakis commentedon Jul 14, 2017
@izquierdo @RabidCicada I believe you need to combine it with the
USE_TZ=Truesetting. For reference see also here.RabidCicada commentedon Jul 16, 2017
USE_TZ is set to True as well documented. This behavior persists.
georgepsarakis commentedon Jul 16, 2017
I think you also need to set
CELERY_ENABLE_UTC=False. Check the discussion in #3753 .bhrutledge commentedon Feb 16, 2018
@auvipy Can you elaborate on why this was closed? Was it fixed? Or is this now expected behavior (counter to the docs)?
kylebebak commentedon May 1, 2018
@georgepsarakis @auvipy
It's obvious this should not have been closed. This is a bug that runs counter to the documentation.
I'm running
celery==4.1.0andDjango==1.11.6.Regardless of what I set for
CELERY_TIMEZONEandTIMEZONE, Celery beat uses UTC. No combination ofTrueandFalseforCELERY_ENABLE_UTCandUSE_TZmakes a difference.georgepsarakis commentedon May 1, 2018
@kylebebak thanks for reporting back. There have been some Celery Beat & timezone fixes in the latest release (4.2.0rc3), is it possible that you can try with that?
kylebebak commentedon May 2, 2018
@georgepsarakis Thank you for the quick reply. I'll try with
4.2.0rc3and let you know if that solves the problem, but I probably won't get around to it for a week or so.I'm in a time zone that's between 5 and 6 hours behind UTC depending on DST, so for the time being I just added 5.5 hours to to all of my
crontabCelery beat tasks.thedrow commentedon May 13, 2018
@kylebebak Have you tried it yet?
Jamim commentedon May 14, 2018
I'm pretty sure this issue is related to #2649.
auvipy commentedon Aug 12, 2018
is this fixed by #3867 ?
sponrad commentedon Jan 1, 2020
@auvipy It appears it isn't.
I just stumbled in here after upgrading from 3.1.25 to 4.x. My periodic tasks are no longer honoring Django's timezone settings just as described by izquierdo.
Django version: 1.11.3
Celery version: tried on 4.0.0 and 4.4.0
Relevant Django settings:
app.conf.timezonereturns None and my periodic tasks fire on UTC time.Setting the celery
timezonesetting (namespaced asCELERY_TIMEZONEfor my install) results inapp.conf.timezonehaving a value.This is a bug in conflict with this documentation:
vanschelven commentedon Jul 7, 2022
AFAICS this problem still exists. Running celery v5.2.7, django 3.2.11.
settings.py:It appears that
app.conf.timezoneis simplyNone.Searching the code (case insensitive) for time_zone reveals only 1 location:
celery/celery/app/utils.py
Line 131 in 515f98b
It appears that's the part that's broken.
Looking at the actual contents of the configuration object, I'd say that the latter
time_zoneshould simply be upper-cased.Fix honor Django's TIME_ZONE setting
Fix honor Django's TIME_ZONE setting