diff --git a/health_check/mixins.py b/health_check/mixins.py index 139707c4..d56167e4 100644 --- a/health_check/mixins.py +++ b/health_check/mixins.py @@ -2,6 +2,7 @@ from collections import OrderedDict from concurrent.futures import ThreadPoolExecutor +from django.db import connections from django.http import Http404 from health_check.conf import HEALTH_CHECK @@ -63,9 +64,10 @@ def _run(plugin): try: return plugin finally: - from django.db import connections - - connections.close_all() + if not HEALTH_CHECK["DISABLE_THREADING"]: + # If this connection was opened by the child thread, + # it must be manually closed. + connections.close_all() def _collect_errors(plugin): if plugin.critical_service: