Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HEALTHCHECK_CELERY_PRIORITY #440

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/contrib.rst
Original file line number Diff line number Diff line change
@@ -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.

4 changes: 4 additions & 0 deletions docs/settings.rst
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion health_check/contrib/celery/backends.py
Original file line number Diff line number Diff line change
@@ -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: