Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Issue with Timezone #67

Open
Jean-PhilippeD opened this issue Jan 26, 2021 · 1 comment
Open

Issue with Timezone #67

Jean-PhilippeD opened this issue Jan 26, 2021 · 1 comment

Comments

@Jean-PhilippeD
Copy link

Hello,

I opened an issue on celery repo (celery/celery#6617)

The last_run_at is saved in UTC in mongo but each time celery pick the task, it schedule it in UTC while I defined not to use UTC.

@Jean-PhilippeD
Copy link
Author

Jean-PhilippeD commented Jan 26, 2021

I manage to get it working (dirty way) by adding a tz replacement when query the MongoScheduleEntry:

import pytz
....
Line 43:
if not self._task.last_run_at:
            self._task.last_run_at = self._default_now()
        else:
            
            europe = pytz.timezone('Europe/Paris')
            if not self._task.last_run_at.tzinfo == self._default_now().tzinfo:
                self._task.last_run_at = self._task.last_run_at.replace(tzinfo=pytz.UTC).astimezone(tz=europe)
        self.last_run_at = self._task.last_run_at

It's clearly not the best way as I put my timezone in the code but for now it does the job ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant