You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker环境下Celery Redis队列长度查询返回0的问题求助

Docker环境下Celery Redis队列长度查询返回0的问题求助

我搭建了一个基于Celery+Redis的Python应用,现在需要查询队列中的任务数量。我尝试执行了一条命令,但输出结果一直是0,可我百分百确定队列里是有任务的,应该是我用错了参数?

我执行的命令:

redis-cli -n 1 -h localhost -p 6379 llen celery

(integer) 0

下面是我的Redis和Celery的Docker配置:

celery:
    build: ./project
    command: celery -A core_app worker  --loglevel=info --concurrency=15 --max-memory-per-child=1000000
    volumes:
      - ./project:/usr/src/app
      - ./project/media:/project/media
      - ./project/logs:/project/logs
    env_file:
      - .env
    environment:
    # environment variables declared in the environment section override env_file
      - DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
      - CELERY_BROKER=redis://redis:6379/0
      - CELERY_BACKEND=redis://redis:6379/0
    depends_on:
      - django
      - redis

  redis:
    build:
      context: ./redis_customization
      dockerfile: Dockerfile
    image: redis:7.2-alpine
    restart: always
    ports:
        - 6379:6379
    # Run the init script
    command: sh -c "./init.sh"
    # Run as privileged to allow the container to change the vm.overcommit_memory setting
    privileged: true

备注:内容来源于stack exchange,提问作者mascai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 18:03:13