0
votes

I'm tring to run a simple scheduled periodic task on a Django app on Heroku using Celery. It works locally and I can watch the task running with:

python manage.py celerybeat

But when I push to heroku and run:

heroku run pythonm manage.py celerybeat

I get:

 [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",)

Snippet settings.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'

Snippet tasks.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"

Snippet requirements.txt

celery==2.5.5
django-celery==2.5.5

What is going wrong?

2

2 Answers

1
votes

You should upgrade to Celery 3.0.7 which fixed a timezone related bug.

0
votes

Not sure of the exact solution but I got around it by adding

USE_L10N = False
USE_TZ = False

to settings.py