From fd93c8f436d1be44d2bfe110ad613cea84bee21f Mon Sep 17 00:00:00 2001 From: mprahl Date: Mon, 9 Dec 2019 08:46:06 -0500 Subject: [PATCH] Force the Celery workers to run only one task at a time This forces the tasks to be run serially. --- module_build_service/__init__.py | 2 ++ module_build_service/config.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/module_build_service/__init__.py b/module_build_service/__init__.py index c79bebc8..2fa61b6a 100644 --- a/module_build_service/__init__.py +++ b/module_build_service/__init__.py @@ -55,6 +55,8 @@ celery_configs = { name[7:]: getattr(conf, name) for name in dir(conf) if name.startswith("celery_") } +# Only allow a single process so that tasks are always serial per worker +celery_configs["worker_concurrency"] = 1 celery_app.conf.update(**celery_configs) diff --git a/module_build_service/config.py b/module_build_service/config.py index cb7582fd..a05b94c8 100644 --- a/module_build_service/config.py +++ b/module_build_service/config.py @@ -670,6 +670,13 @@ class Config(object): "default": 30, "desc": "The timeout configuration for dnf operations, in seconds." }, + "celery_worker_prefetch_multiplier": { + "type": int, + "default": 1, + "desc": "This defaults to 1 so that the worker doesn't fetch more messages than it can " + "handle at a time. This so that general tasks aren't starved when running " + "a long handler.", + }, } def __init__(self, conf_section_obj):