It returns no errors, however when running celery -A mysite beat -l info
& celery -A mysite worker -l info
the task doesn't happen. When trying the same structure in another Django project it works fine.
Help please!
My code:
mysite/settings.py (Only CELERY part)
BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Africa/Nairobi'
mysite/init.py
from __future__ import absolute_import
from .celery import app as celery_app
mysite/celery.py
from __future__ import absolute_import
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
app = Celery('mysite')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
personal/tasks.py
from celery.task.schedules import crontab
from celery.decorators import periodic_task
from celery.utils.log import get_task_logger
logger = get_task_logger(__name__)
@periodic_task(
run_every=(crontab(minute='*/1')),
name="task_deleteFiles",
ignore_result=True
)
def task_deleteFiles():
logger.info("Files Deleted")
PS: If necessary I can post the outputs from Celery
Apparently by deleting app.py and app.pyc (which were under the personal file) celery works perfectly normal. Python was possibly trying to import somehow the module, strangely it didn't return any error messages.