0

我正在尝试使用 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

出了什么问题?

4

2 回答 2

1

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

于 2012-08-24T20:38:10.353 回答
0

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

USE_L10N = False
USE_TZ = False

到 settings.py

于 2012-08-27T10:53:00.290 回答