New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

celery 4.1 ETA time is not correct #4221

fanjindong opened this Issue Aug 22, 2017 · 8 comments


None yet
7 participants

fanjindong commented Aug 22, 2017


from celery import Celery, Task, exceptions, platforms
from connection import ConnectionTask
from datetime import timedelta
import conf

demo = Celery('demo', broker=conf.MQ_BROKER)

        'demo-add': {
            'task': 'demo.add',
            'schedule': timedelta(seconds=15),
            'options': {'queue': conf.MQ_DEMO},
            'args': [2, 8],

@demo.task(base=ConnectionTask, bind=True, ignore_result=True, max_retries=5)
def add(self, x, y):
    if x==1:
    return x + y

err behavior

[2017-08-22 16:00:53,025: INFO/MainProcess] Received task: demo.add[5359c683-28c5-4265-bc77-a02807e7827a]  
[2017-08-22 16:00:53,028: INFO/ForkPoolWorker-2] Task demo.add[5359c683-28c5-4265-bc77-a02807e7827a] retry: Retry in 60s
[2017-08-22 16:00:53,035: INFO/MainProcess] Received task: demo.add[5359c683-28c5-4265-bc77-a02807e7827a]  ETA:[2017-08-22 08:01:53.026906+08:06]

look: ETA:[...] time is not correct,but celery 4.0.2 this is correct


This comment has been minimized.

djluo commented Aug 23, 2017

Sorry that there is no reply in English

import pytz
import datetime
def EtaWithTZ(value):
TZ = pytz.timezone(CELERY_TIMEZONE)
ETA = datetime.datetime.strptime(value, "%Y-%m-%d %H:%M:%S")
return TZ.localize(ETA)


eta=EtaWithTZ("2017-08-23 10:30:00")


This comment has been minimized.

ldsink commented Aug 23, 2017

#4173 pull request maybe fix this problem.


This comment has been minimized.

fanjindong commented Aug 23, 2017

@djluo 木有事,反正我看得懂。


This comment has been minimized.

fanjindong commented Aug 23, 2017

@ldsink will be fix in celery4.2 ?


This comment has been minimized.

vst commented Sep 2, 2017

Confirming that the pull request fixed the issue which I started experiencing after moving from v4.0.2 to v4.1.0.

Problem was that the cron job was triggering at the specified time but in UTC time instead of the given timezone. I suspect that this was due to my USE_TZ = False (I need to keep it as is unlike the documentation recommends).

For reference, my settings are:

## Django settings:
USE_TZ = False
TIME_ZONE = '<Some Timezone>'

## Celery Application Settings:

This comment has been minimized.


georgepsarakis commented Sep 2, 2017

@vst thanks for confirming!


This comment has been minimized.

mbarchein commented Sep 19, 2017

I think this issue also affects retry(countdown=N). With no code changes in my Django project, with Celery 4.0.2 retry(countdown=5) works as expected. Celery 4.1.0 requeues the task but it doesn't get executed in the desired countdown seconds, but several minutes later.


This comment has been minimized.


thedrow commented Sep 19, 2017

Since this is fixed in #4173 I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment