From 0f7278f30c47cbbc12a9b466d62a642c69565cfb Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:16:22 +0100 Subject: [PATCH 1/3] Add HEALTHCHECK_CELERY_PRIORITY --- health_check/contrib/celery/backends.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/health_check/contrib/celery/backends.py b/health_check/contrib/celery/backends.py index 77afbdc5..431f7a09 100644 --- a/health_check/contrib/celery/backends.py +++ b/health_check/contrib/celery/backends.py @@ -12,10 +12,11 @@ def check_status(self): timeout = getattr(settings, "HEALTHCHECK_CELERY_TIMEOUT", 3) result_timeout = getattr(settings, "HEALTHCHECK_CELERY_RESULT_TIMEOUT", timeout) queue_timeout = getattr(settings, "HEALTHCHECK_CELERY_QUEUE_TIMEOUT", timeout) + priority = getattr(settings, "HEALTHCHECK_CELERY_PRIORITY", None) try: result = add.apply_async( - args=[4, 4], expires=queue_timeout, queue=self.queue + args=[4, 4], expires=queue_timeout, queue=self.queue, priority=priority ) result.get(timeout=result_timeout) if result.result != 8: From b172fc4747501809358c5d77dda790e2c8b27598 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:45:45 +0100 Subject: [PATCH 2/3] Add docs --- docs/settings.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/settings.rst b/docs/settings.rst index f17c1dbc..dbb117c6 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -95,3 +95,7 @@ Using `django.settings` you may exert more fine-grained control over the behavio - Number - `3` - Specifies the maximum total time for a task to complete and return a result, including queue time. + * - `HEALTHCHECK_CELERY_PRIORITY` + - Number + - `None` + - Specifies the healthcheck task priority. From 3954e3d26a96e8dac7c77c775abea66c7bd3222c Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 24 Dec 2024 09:58:28 +0100 Subject: [PATCH 3/3] Add docs --- docs/contrib.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/contrib.rst b/docs/contrib.rst index 7332f155..832d5666 100644 --- a/docs/contrib.rst +++ b/docs/contrib.rst @@ -43,6 +43,7 @@ If you are using Celery you may choose between two different Celery checks. `health_check.contrib.celery` sends a task to the queue and it expects that task to be executed in `HEALTHCHECK_CELERY_TIMEOUT` seconds which by default is three seconds. +The task is sent with a priority of `HEALTHCHECK_CELERY_PRIORITY` (default priority by default). You may override that in your Django settings module. This check is suitable for use cases which require that tasks can be processed frequently all the time.