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

Only close DB connections when using threading #438

Open
wants to merge 1 commit 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
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
Loading