2

environment: Django3.1, celery5.2 Django setting.py

CELERY_RESULT_BACKEND = 'django-db'
CELERY_BROKER_URL = 'redis://127.0.0.1/0'
CELERYD_CONCURRENCY = 2  # 并发worker数
# CELERYD_PREFETCH_MULTIPLIER=1
CELERYD_FORCE_EXECV = True 
CELERYD_MAX_TASKS_PER_CHILD = 50  

celery.py

import os

from celery import Celery

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'san.settings')

app = Celery('san')
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django apps.
app.autodiscover_tasks()

启动命令:celery -A san worker -l INFO -P gevent

-------------- [email protected] v5.2.3 (dawn-chorus) --- ***** ----- -- ******* ---- Linux-3.10.0-327.el7.x86_64-x86_64-with-glibc2.17 2022-02-18 14:31:44

  • *** --- * ---
  • ** ---------- [config]
  • ** ---------- .> app: san:0x7f7d31a811c0
  • ** ---------- .> transport: redis://127.0.0.1:6379/0
  • ** ---------- .> results:
  • *** --- * --- .> concurrency: 4 (gevent) -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) --- ***** ----- -------------- [queues] .> celery exchange=celery(direct) key=celery

concurrency: 4,why does my configuration not take effect? Specifying the '-c' parameter in the startup command is valid.

  • *** --- * --- .> concurrency: 2 (gevent)

What can I do to make my configuration work?

The rest of my configuration works,such as CELERY_BROKER_URL,CELERY_RESULT_BACKEND

3
  • not clear on what help you are looking for? are you saying the -c option is not working for you while starting the worker process? Commented Feb 19, 2022 at 5:05
  • The CELERYD_CONCURRENCY configuration does not work in a Django configuration. What should I do to make setting.py's CELERYD_CONCURRENCY configuration work Commented Feb 21, 2022 at 1:40
  • CELERY_RESULT_BACKEND,CELERY_BROKER_URL are in effect in the configuration, but CELERYD_CONCURRENCY is not Commented Feb 21, 2022 at 1:42

1 Answer 1

2
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.

Change CELERYD CONCURRENCY to CELERY_WORKER_CONCURRENCY

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.