Celery scheduled tasks problems with Timezone

前端 未结 3 1631
一向
一向 2021-01-12 09:20

I\'m using celery in a server where server time is now BST, and suddenly my scheduled tasks are executing one hour before! Previously, serv

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-12 10:11

    I find it strange that if we set the celery_time zone, It will adjust the eta time by add the local time to utc. but, the celery eta clock seems to trigger by utc time. now the utc time is the time+celery timezone which is wrong.

    I guess the @bgschiller using the utc as default time zone is a way to solve this..

    def celery_localtime_util(t):
        bj_tz = pytz.timezone('*')
        bj_dt = bj_tz.localize(t)
        return bj_dt.astimezone(pytz.UTC)
    

    use this works...

提交回复
热议问题