Nikitka
Nikitka

Reputation: 428

Celery tasks doesn't works

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.

Upvotes: 1

Views: 2834

Answers (1)

bluebird_lboro
bluebird_lboro

Reputation: 601

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.

Upvotes: 1

Related Questions