worker_concurrency 配置对 celery 无效
worker_concurrency configuration not valid for celery
环境:Django3.1、celery5.2
姜戈 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
---------------- celery@dev.10.1.1.209 v5.2.3(黎明合唱)
--- ***** -----
-- ******* ---- Linux-3.10.0-327.el7.x86_64-x86_64-with-glibc2.17 2022-02-18 14:31:44
- *** --- * ---
- ** ---------- [配置]
- ** ---------- .> 应用程序:san:0x7f7d31a811c0
- ** ---------- .> 传输:redis://127.0.0.1:6379/0
- ** ---------- .> 结果:
- *** --- * --- .> 并发数:4 (gevent)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [队列]
.> celery exchange=celery(直接) key=celery
concurrency: 4,为什么我的配置没有生效?
在启动命令中指定'-c'参数有效。
- *** --- * --- .> 并发数:2 (gevent)
我该怎么做才能让我的配置生效?
我的其余配置有效,例如 CELERY_BROKER_URL
、CELERY_RESULT_BACKEND
# 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.
将CELERYD CONCURRENCY
更改为CELERY_WORKER_CONCURRENCY
环境:Django3.1、celery5.2 姜戈 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
---------------- celery@dev.10.1.1.209 v5.2.3(黎明合唱) --- ***** ----- -- ******* ---- Linux-3.10.0-327.el7.x86_64-x86_64-with-glibc2.17 2022-02-18 14:31:44
- *** --- * ---
- ** ---------- [配置]
- ** ---------- .> 应用程序:san:0x7f7d31a811c0
- ** ---------- .> 传输:redis://127.0.0.1:6379/0
- ** ---------- .> 结果:
- *** --- * --- .> 并发数:4 (gevent) -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) --- ***** ----- -------------- [队列] .> celery exchange=celery(直接) key=celery
concurrency: 4,为什么我的配置没有生效? 在启动命令中指定'-c'参数有效。
- *** --- * --- .> 并发数:2 (gevent)
我该怎么做才能让我的配置生效?
我的其余配置有效,例如 CELERY_BROKER_URL
、CELERY_RESULT_BACKEND
# 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.
将CELERYD CONCURRENCY
更改为CELERY_WORKER_CONCURRENCY