Я создал файл сельдерея и файл задачи, но когда я запускаю сервер Redis, я не вижу загрузки своих задач.ниже мой celery.py
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from celery.schedules import crontab
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'EmailBot.settings')
app = Celery('Emailbot',broker='ampq://localhost',backend='ampq: //localhost', include=['EmailBot'])
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
app.conf.broker_url = 'redis://localhost:6379/0'
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
CELERYBEAT_SCHEDULE = {
'every-day': {
'task': 'Bot.tasks.add',
'schedule': crontab(minute=1),
},
}
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
tasks.py
from __future__ import absolute_import, unicode_literals
from celery import shared_task
from celery import task
@task
def add():
print("hiiiii")
ниже мой init .py
from __future__ import absolute_import, unicode_literals
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ('celery_app',)
я добавилследующие строки в settings.py
CELERY_RESULT_BACKEND = 'django-db'
CELERY_RESULT_BACKEND = 'django-cache'