3

I'm following this guide: http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

My proj.celery file:

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from celery.schedules import crontab

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hc.settings')

app = Celery('hc')

app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()


@app.task
def debug_task(a):
    print a
app.conf.beat_schedule = {
    # Executes every Monday morning at 7:30 a.m.
    'debug-every-minute': {
        'task': 'tasks.debug_task',
        'schedule': crontab(),
        'args': ("BLa BLA BlA", ),
    },
}

also, I've added periodic task into /admin/django_celery_beat/

I understand that it's makes not sense to use both app.conf.beat_schedule and periodic_task in admin but I don't see expecting entries after

Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

(I expect that Bla bla will be written under that) Where I'm wrong?

1
  • You will not see any print statements on the console of your django application because the celery task will be run in another process. If you started celery with celery -A proj worker -l info in a shell you will see the output there. Commented Feb 1, 2017 at 11:52

2 Answers 2

7

Run celery by

celery -A hc worker -B -l info
Sign up to request clarification or add additional context in comments.

1 Comment

which stands for celery --app hc worker --beat --loglevel=INFO
0

You have to run the command python manage.py celery beat to start your periodic task and see the results. Only you can see the print statement results of celery task in your celery shell rather than the normal Django runserver shell.

3 Comments

./manage.py celery beat Unknown command: 'celery' Type 'manage.py help' for usage. 'django_celery_beat', 'django_celery_results', 'celery', are in INSTALLED_APPS
This only works with django-celery installed which is not mandatory.
use celery -A hc beat -l info

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.