From 54e86c29d13fe8d3f852e97a201d6eb8ef1675da Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 20 Nov 2026 13:23:02 -0300 Subject: [PATCH] fix(settings): size DB pool from WEB_THREADS and PROCRASTINATE_WORKER_CONCURRENCY --- app/WYGIWYH/settings.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/WYGIWYH/settings.py b/app/WYGIWYH/settings.py index 316dd9ff..2f85a68d 100644 --- a/app/WYGIWYH/settings.py +++ b/app/WYGIWYH/settings.py @@ -147,7 +147,12 @@ WSGI_APPLICATION = "WYGIWYH.wsgi.application" # Database # https://docs.djangoproject.com/en/5.1/ref/settings/#databases -THREADS = int(os.getenv("GUNICORN_THREADS", 1)) +# Web and task worker share these settings, so size every pool for whichever runs more threads. +# The pool opens connections on demand (min_size=1), so the larger cap costs nothing when idle. +THREADS = max( + int(os.getenv("WEB_THREADS") or os.getenv("GUNICORN_THREADS") or 1), + int(os.getenv("PROCRASTINATE_WORKER_CONCURRENCY") or 1), +) MAX_POOL_SIZE = THREADS + 1 DATABASES = {