Heroku上的芹菜时间/日期错误



我正在使用Celery在Heroku上的Django应用程序上运行一个简单的定期任务。它在本地工作,我可以用观看任务的运行

python manage.py celerybeat

但当我推到heroku并运行时:

heroku run pythonm manage.py celerybeat

我得到:

 [2012-08-24 13:31:43,185: WARNING/MainProcess] __    -    ... __   -        _
    Configuration ->
        . broker -> django://localhost//
        . loader -> djcelery.loaders.DjangoLoader
        . scheduler -> djcelery.schedulers.DatabaseScheduler
        . logfile -> [stderr]@INFO
        . maxinterval -> 5.00 minutes (300s)
    [2012-08-24 13:31:43,186: INFO/MainProcess] Celerybeat: Starting...
    [2012-08-24 13:31:43,325: CRITICAL/MainProcess] 
celerybeat raised exception <type 'exceptions.TypeError'>: 
TypeError("can't compare offset-naive and offset-aware datetimes",)

代码段设置.py

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'gunicorn',
    'items',
    'djcelery', 
    'kombu.transport.django'
)

import djcelery
import djcelery.schedulers
djcelery.setup_loader()
BROKER_URL = "django://"
CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'America/New_York'
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
TIME_ZONE = 'America/New_York'

代码段任务.py

from celery.task import PeriodicTask
from celery.registry import tasks
from datetime import timedelta
from datetime import datetime
import sys
from subprocess import Popen, PIPE
from celery.task import task, periodic_task
from celery.schedules import crontab
import time, datetime
@periodic_task(run_every=crontab(hour="*", minute="*", day_of_week="*"))
def test_task():
    print "TASK RUNNING"

代码段要求.txt

celery==2.5.5
django-celery==2.5.5

出了什么问题?

您应该升级到Celery 3.0.7,它修复了一个与时区相关的错误。

不确定确切的解决方案,但我通过添加绕过了它

USE_L10N = False
USE_TZ = False

设置。py

相关内容

  • 没有找到相关文章

最新更新