I have become unable to use the inspect() function within Celery to see the active and reserved items within the queue. Instead of returning something like {u'celery@mymachine': []}
it always returns None
.
This began after I changed my Docker from using python:3.6-alpine to python:3.6, but now, even after I reverted back to alpine I still receive this behaviour. I have tried everything suggested here: Celery scheduled list returns None but none of it seems to work either.
I have included a minimal example below that shows my issue
If anyone has any ideas what may be causing this I would be very grateful
DockerFile:
FROM python:3.6-alpine
ENV CELERY_BROKER_URL redis://redis:6379/0
ENV CELERY_RESULT_BACKEND redis://redis:6379/0
ENV C_FORCE_ROOT true
WORKDIR /usr/src/app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD celery -A celeryExample worker --concurrency=1 --loglevel=info
Docker-compose:
version: '3'
services:
redis:
image: redis
ports:
- 6379:6379
celery:
build:
context: .
dockerfile: Dockerfile.celery
depends_on:
- redis
volumes:
- .:/usr/src/app
requirements.txt
celery
celeryExample.py
from celery import Celery
import celeryconfig
broker_url = os.environ.get('broker_url', 'redis://localhost:6379/0'),
result_backend = os.environ.get('result_backend', 'redis://localhost:6379/0')
app = Celery('server', broker = broker_url,
backend = result_backend)
app.config_from_object(celeryconfig)
@app.task
def add(x, y):
return x + y
celeryconfig:
worker_prefetch_multiplier = 1
worker_concurrency = 1
active.py:
from celery import Celery
import celeryconfig
from celery.task.control import inspect
import os
broker_url = os.environ.get('broker_url', 'redis://localhost:6379/0'),
result_backend = os.environ.get('result_backend', 'redis://localhost:6379/0')
app = Celery('server', broker = broker_url,
backend = result_backend)
app.config_from_object(celeryconfig)
i = inspect()
q = i.active()
print(q)