celerybeat-mongo
celerybeat-mongo copied to clipboard
Issue with Timezone
Hello,
I opened an issue on celery repo (https://github.com/celery/celery/issues/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.
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 ;)