[英]Correct timesettings in Django for Celery
Im wondering how to correctly use timesettings in django and celery. 我想知道如何在django和celery中正确使用时间设置。
Here is what I have: 这是我所拥有的:
TIME_ZONE = 'Europe/Oslo'
CELERY_TIMEZONE = 'Europe/Oslo'
CELERY_ENABLE_UTC = True
USE_TZ = True
TZINFO = 'UTC'
But the timestamp on my Celery task is ahead by two hours. 但是我Celery任务的时间戳提前了两个小时。 How can I fix it?
我该如何解决?
Using: 使用:
Django - 1.6b2 Django-1.6b2
celery - 3.0.23 芹菜-3.0.23
django-celery - 3.0.23 django-celery-3.0.23
You can use TZ default environment variable. 您可以使用TZ默认环境变量。 Django will automatically use it with calling: http://docs.python.org/2/library/time.html#time.tzset If your celery runs from django, it will work there too.
Django会自动通过调用以下命令来使用它: http : //docs.python.org/2/library/time.html#time.tzset如果您的芹菜从django运行,它也将在那运行。
Also you could use something like: 您也可以使用类似:
os.environ['TZ'] = 'your timezone' os.environ ['TZ'] ='您的时区'
at the beginning of ( manage.py or wsgi.py ) in your local installation. 在本地安装的开始(manage.py或wsgi.py)的开头。
I think you might be hitting a bug in django-celery that I am also running into. 我认为您可能遇到了我也遇到的django-celery中的错误。 There were timezone related changes in the last few releases of django-celery and this bug first showed up for me when I updated from 3.0.19 to 3.0.23.
在django-celery的最近几个发行版中,与时区相关的更改,并且当我从3.0.19更新到3.0.23时,这个错误首先向我显示。
I asked about this on the #celery IRC chat and was told that the django admin based celery task view is not that great and I should be using something like Flower ( https://github.com/mher/flower ) to monitor my tasks. 我在#celery IRC聊天中询问了此问题,并被告知基于django管理员的celery任务视图不是很好,我应该使用Flower( https://github.com/mher/flower )之类的东西来监视我的任务。
I installed and ran Flower and it did not suffer from the same timestamp issues that the django-celery admin based view does. 我安装并运行了Flower,它没有像基于django-celery admin的视图那样遇到相同的时间戳问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.