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, 4 insertions, 5 deletions
diff --git a/django/core/management/base.py b/django/core/management/base.py
index 41b6b0fa91..b53b414fdb 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -5,6 +5,7 @@ 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
@@ -297,12 +298,10 @@ class BaseCommand:
self.stderr.write('%s: %s' % (e.__class__.__name__, e))
sys.exit(1)
finally:
- try:
+ # Ignore if connections aren't setup at this point (e.g. no
+ # configured settings).
+ with suppress(ImproperlyConfigured):
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):
"""