I'm working on a drf app where I need to use celery. I'm trying to run a simple task to make sure the set up is solid for later.
settings.py:
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
tasks.py:
@shared_task
def add(x, y):
print(f"Running add({x}, {y})")
return x + y
I've opened 3 tabs and running these 3 in each:
1. python3 manage.py runserver
2. redis-server
3. celery -A sauftrag_social worker --loglevel=info
All of them are ran successfully and I see the add task in [tasks] part in the celery worker tab.
I'm calling the task like this: result = add.delay(2, 3)
After running about 10 minutes it's returning this error message:
kombu.exceptions.OperationalError: Timeout connecting to server