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

tasks registered by Camera are shifted in time

Open jerzyk opened this issue 10 years ago • 3 comments

this is possible bug related to timezone handling in Camera, theoretically that was fixed with the latest release, but what I can see in the code, there is a double timezone "verification".

File snapshot.py, lines 86-97:

            'eta': maybe_make_aware(maybe_iso8601(task.eta)),
            'expires': maybe_make_aware(maybe_iso8601(task.expires)),
            ...
            'tstamp': aware_tstamp(task.timestamp),

and then in lines 125-127:

        for datefield in ('eta', 'expires', 'tstamp'):
            # Brute force trying to fix #183
            setattr(obj, datefield, maybe_make_aware(getattr(obj, datefield)))

jerzyk avatar Nov 16 '13 20:11 jerzyk

ach... this piece of code is responsible:

def aware_tstamp(secs):
    """Event timestamps uses the local timezone."""
    return maybe_make_aware(datetime.fromtimestamp(secs))

there should be utcfromtimestamp, I'm not sure if only or there should be check against CELERY_ENABLE_UTC and USE_TZ from settings.

jerzyk avatar Nov 16 '13 21:11 jerzyk

Do you have USE_TZ and ENABLE_UTC enabled?

ask avatar Nov 19 '13 18:11 ask

In our settings:

USE_TZ = True
CELERY_ENABLE_UTC = USE_TZ

tongwang avatar Nov 19 '13 18:11 tongwang