fix(pytest): call stop for all instances even if stop raise exception (#4339)

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2024-12-18 18:03:37 +02:00 committed by GitHub
parent 682a3f6b15
commit 3f68028c08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -453,9 +453,19 @@ class DflyInstanceFactory:
async def stop_all(self):
"""Stop all launched instances."""
exceptions = [] # To collect exceptions
for instance in self.instances:
await instance.close_clients()
instance.stop()
try:
instance.stop()
except Exception as e:
exceptions.append(e) # Collect the exception
if exceptions:
first_exception = exceptions[0]
raise Exception(
f"One or more errors occurred while stopping instances. "
f"First exception: {first_exception}"
) from first_exception
def __repr__(self) -> str:
return f"Factory({self.args})"