Algorithmatic
Algorithmatic

Reputation: 1892

Celery apply_async with eta executing faster than it should

>>> def elp(min):
...     when = datetime.now() + timedelta(minutes=min)
...     print when
...     r = add.apply_async(args=[500,500],eta=when)
...     start = time.time()
...     r.get()
...     end = time.time()
...     elapsed = end-start
...     print elapsed
...
>>> elp(10)

2014-11-08 04:38:01.745000
1.00200009346

Where as when using countdown

>>> def elp_countdown(min):
...     r = add.apply_async(args=[500,500],countdown=(min*60))
...     start = time.time()
...     r.get()
...     end = time.time()
...     elapsed = end-start
...     print elapsed
...
>>> elp_countdown(0.5)
30.1380000114

Why does the task gets executed faster than its suppose when using eta?

my add task is as follows,

@task()
def add(x, y):
    return x + y

Celery verison: 3.1.16 (Cipater)

Upvotes: 0

Views: 1984

Answers (1)

Algorithmatic
Algorithmatic

Reputation: 1892

So after some research and lot's of reading, it turns out that I needed to pass a utc datetime to celery, since it's time zone is configured by default to be in UTC.

In case anyone is wondering, changing to this:

when = datetime.utcnow() + timedelta(minutes=min)

instead of

when = datetime.now() + timedelta(minutes=min)

will make it work as it should.

Upvotes: 1

Related Questions