summaryrefslogtreecommitdiff
path: root/django/core/management/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/core/management/base.py')
-rw-r--r--django/core/management/base.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/core/management/base.py b/django/core/management/base.py
index b53b414fdb..41b6b0fa91 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -5,7 +5,6 @@ be executed through ``django-admin`` or ``manage.py``).
import os
import sys
from argparse import ArgumentParser
-from contextlib import suppress
from io import TextIOBase
import django
@@ -298,10 +297,12 @@ class BaseCommand:
self.stderr.write('%s: %s' % (e.__class__.__name__, e))
sys.exit(1)
finally:
- # Ignore if connections aren't setup at this point (e.g. no
- # configured settings).
- with suppress(ImproperlyConfigured):
+ try:
connections.close_all()
+ except ImproperlyConfigured:
+ # Ignore if connections aren't setup at this point (e.g. no
+ # configured settings).
+ pass
def execute(self, *args, **options):
"""