1

Celery docs say that Celery 3.1 can work with django out of box. But tasks not working. I have tasks.py:

from celery import task
from datetime import timedelta

@task.periodic_task(run_every=timedelta(seconds=20), ignore_result=True)
    def disable_not_confirmed_users():
        print "start"

Configs:

from kombu import Exchange, Queue

CELERY_SEND_TASK_ERROR_EMAILS = True
BROKER_URL = 'amqp://guest@localhost//'
CELERY_DEFAULT_QUEUE = 'project-queue'
CELERY_DEFAULT_EXCHANGE = 'project-queue'
CELERY_DEFAULT_ROUTING_KEY = 'project-queue'
CELERY_QUEUES = (
    Queue('project-queue', Exchange('project-queue'), routing_key='project-queue'),
)

project/celery.py from future import absolute_import

import os

from celery import Celery

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')

from django.conf import settings


app = Celery('project')

app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

Run celery: celery -A project worker --loglevel=INFO

But nothing not happend.

5
  • celery work, but task doesn't run Commented Jan 19, 2016 at 11:07
  • Try to run celery as celery -A fratchy worker -B --loglevel=INFO Commented Jan 19, 2016 at 11:10
  • instead of print, try using the logging module to log an INFO mesage Commented Jan 19, 2016 at 11:28
  • Dima Kudosh, right. It helped. Commented Jan 19, 2016 at 12:45
  • Have you been running celery beat? Workers are to execute tasks, but celery beat is what puts the periodic tasks in queue for execution when their time ticks. Commented Jan 20, 2016 at 14:08

1 Answer 1

1

you should use celery beat to run periodic task.

celery -A project worker --loglevel=INFO

starts the worker, which does the actually work.

celery -A proj beat

starts the beat service, which asks the work to do the job.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.