diff --git a/hobo/multitenant/management/commands/tenant_command.py b/hobo/multitenant/management/commands/tenant_command.py index 5ce72ef..ec267e1 100644 --- a/hobo/multitenant/management/commands/tenant_command.py +++ b/hobo/multitenant/management/commands/tenant_command.py @@ -63,13 +63,6 @@ def run_command_from_argv(command, argv): '%s: %s: %s' % (connection.get_tenant(), e.__class__.__name__, exception_to_text(e)) ) return e - finally: - try: - connections.close_all() - except ImproperlyConfigured: - # Ignore if connections aren't setup at this point (e.g. no - # configured settings). - pass class Command(InteractiveTenantOption, BaseCommand): @@ -152,6 +145,12 @@ class Command(InteractiveTenantOption, BaseCommand): error = run_command_from_argv(klass, args) if error: errors.append(error) + try: + connections.close_all() + except ImproperlyConfigured: + # Ignore if connections aren't setup at this point (e.g. no + # configured settings). + pass if errors: self.stderr.write('Command failed on multiple tenants') sys.exit(1)