Skip to content

Commit 57cb9ba

Browse files
Disable atomic requests for health-check view
1 parent d516616 commit 57cb9ba

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

health_check/views.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import re
22

3+
from django.db import transaction
34
from django.http import HttpResponse, JsonResponse
45
from django.utils.decorators import method_decorator
56
from django.views.decorators.cache import never_cache
@@ -78,8 +79,21 @@ def __eq__(self, other):
7879
def __lt__(self, other):
7980
return self.weight.__lt__(other.weight)
8081

81-
82+
@transaction.non_atomic_requests
8283
class MainView(CheckMixin, TemplateView):
84+
"""
85+
Views for healthcheck endpoints.
86+
87+
Disable atomic requests, because when `ATOMIC_REQUEST=True` django would
88+
still go to db to check the state, meaning there would an error when db is
89+
not available, which would result in django error 500 page rather than
90+
HealthCheck 500 response.
91+
92+
Note: these endpoints are still dependant on db, if you logged in via
93+
browser, or in other words have session cookies.
94+
95+
"""
96+
8397
template_name = "health_check/index.html"
8498

8599
@method_decorator(never_cache)

0 commit comments

Comments
 (0)