skip to Main Content

i am trying to run the celery -A project worker -l info. But each time it returns an error like init got unexpected error. Kindly Help.
Thanks in advance.

my settings file:

CELERY_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'

celery file:

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

# setting the Django settings module.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')

# Looks up for task modules in Django applications and loads them
app.autodiscover_tasks()


@app.task(bind=True)
def debug_task():
    print('Request')

init file

from __future__ import absolute_import

# 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

2

Answers


  1. I just solved the problem by installing a Redis bundle.

    pip install "celery[redis]"
    
    Login or Signup to reply.
  2. Your issue are most likely due to a regression in Kombu when connecting to redis. The way forward is either to follow the instructions here: https://github.com/celery/kombu/issues/1419 or to pin Kombu to a lower version. (I pinned Kombu to 5.0.2)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search