'Run Django Celery Periodically
I have the task file tasks.py
@shared_task
def add(x, y):
print(x + y)
return x + y
and celery.py
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from celery.schedules import crontab
# setting the Django settings module.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'onboarding.settings')
app = Celery('onboarding',broker='pyamqp://guest@localhost//')
app.config_from_object('django.conf:settings', namespace='CELERY')
# Looks up for task modules in Django applications and loads them
app.autodiscover_tasks()
app.conf.beat_schedule = {
# Executes every Monday morning at 7:30 a.m.
'add-every-1-seconds': {
'task': 'tasks.add',
'schedule': 30,
'args': (16, 16),
},
}
when i run celery -A onboarding beat
and celery -A onboarding worker
Seems it is adding tasks but it is not executing the tasks required. What can be the problem
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


