Skip to content

Commit 84297aa

Browse files
authored
Add HEALTHCHECK_CELERY_PRIORITY (#440)
* Add HEALTHCHECK_CELERY_PRIORITY * Add docs * Add docs
1 parent b0e2c4c commit 84297aa

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

docs/contrib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ If you are using Celery you may choose between two different Celery checks.
4343

4444
`health_check.contrib.celery` sends a task to the queue and it expects that task
4545
to be executed in `HEALTHCHECK_CELERY_TIMEOUT` seconds which by default is three seconds.
46+
The task is sent with a priority of `HEALTHCHECK_CELERY_PRIORITY` (default priority by default).
4647
You may override that in your Django settings module. This check is suitable for use cases
4748
which require that tasks can be processed frequently all the time.
4849

docs/settings.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,7 @@ Using `django.settings` you may exert more fine-grained control over the behavio
9595
- Number
9696
- `3`
9797
- Specifies the maximum total time for a task to complete and return a result, including queue time.
98+
* - `HEALTHCHECK_CELERY_PRIORITY`
99+
- Number
100+
- `None`
101+
- Specifies the healthcheck task priority.

health_check/contrib/celery/backends.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ def check_status(self):
1212
timeout = getattr(settings, "HEALTHCHECK_CELERY_TIMEOUT", 3)
1313
result_timeout = getattr(settings, "HEALTHCHECK_CELERY_RESULT_TIMEOUT", timeout)
1414
queue_timeout = getattr(settings, "HEALTHCHECK_CELERY_QUEUE_TIMEOUT", timeout)
15+
priority = getattr(settings, "HEALTHCHECK_CELERY_PRIORITY", None)
1516

1617
try:
1718
result = add.apply_async(
18-
args=[4, 4], expires=queue_timeout, queue=self.queue
19+
args=[4, 4], expires=queue_timeout, queue=self.queue, priority=priority
1920
)
2021
result.get(timeout=result_timeout)
2122
if result.result != 8:

0 commit comments

Comments
 (0)