File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import re
22
3+ from django .db import transaction
34from django .http import HttpResponse , JsonResponse
45from django .utils .decorators import method_decorator
56from 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
8283class 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 )
You can’t perform that action at this time.
0 commit comments