From 8eddb4b95bd7b7572d155ead54456e6c9052ca73 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 14 Oct 2021 12:32:30 +0200 Subject: [PATCH] admin: check for debug in worker count api Signed-off-by: Jens Langhammer --- authentik/admin/api/workers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/authentik/admin/api/workers.py b/authentik/admin/api/workers.py index c4fe3f5ba..5b8e12848 100644 --- a/authentik/admin/api/workers.py +++ b/authentik/admin/api/workers.py @@ -1,4 +1,5 @@ """authentik administration overview""" +from django.conf import settings from drf_spectacular.utils import extend_schema, inline_serializer from prometheus_client import Gauge from rest_framework.fields import IntegerField @@ -21,4 +22,7 @@ class WorkerView(APIView): def get(self, request: Request) -> Response: """Get currently connected worker count.""" count = len(CELERY_APP.control.ping(timeout=0.5)) + # In debug we run with `CELERY_TASK_ALWAYS_EAGER`, so tasks are ran on the main process + if settings.DEBUG: + count += 1 return Response({"count": count})