Celery Flower show GMT time instead local timezone

2019-06-13 20:56发布

问题:

I've installed Flower via pip, all work's fine, but when i see task time in flower it show me GMT time instead time in timezone. Flower task options

  • Pythnon - 3.4
  • Django - 1.8.7
  • Redis server v=2.8.17
  • Celery - 3.1.19

My celery and django conf:

TIME_ZONE = 'Europe/Moscow'
USE_I18N = True
USE_L10N = True
USE_TZ = True
CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'Europe/Moscow'

I've tried to change TIME_ZONE but it gives nothing, or set CELERY_ENABLE_UTS = False If i change celery timezone properties - it's changed in workers log. HW time on server is 13:52 too.

In the worker log time is displayed correctly.

[2016-01-13 13:52:44,510: INFO/MainProcess] Received task: ***task[f652c89d-3f1b-4795-9e41-064ceb33b462]
[2016-01-13 13:52:45,529: INFO/MainProcess] Task ***task[f652c89d-3f1b-4795-9e41-064ceb33b462] succeeded in 1.0084812670002066s:

回答1:

setting CELERY_ENABLE_UTC = False, if your celery version is higher than 3.0 , so that keep same with celery beat and works well for all schedules.

CELERY_ENABLE_UTC = False

setting CELERY_TIMEZONE = 'Asia/Shanghai'. so that flower time display well.

CELERY_TIMEZONE = 'Asia/Shanghai'

in Flask, settings should be push into conf obj by: celery.conf['CELERY_ENABLE_UTC'] = CELERY_ENABLE_UTC celery.conf['CELERY_TIMEZONE'] = CELERY_TIMEZONE