Skip to content

Commit

Permalink
Only close DB connections when using threading
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOrangeOne committed Oct 11, 2024
1 parent b0e2c4c commit 74f0477
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions health_check/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 74f0477

Please sign in to comment.