tenant_command: don't close sql sessions after each tenant (#65388)

This commit is contained in:
Pierre Ducroquet 2022-05-18 12:26:10 +02:00
parent 8da569728c
commit 71fd12f260
1 changed files with 6 additions and 7 deletions

View File

@ -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)