Skip to content

Commit 3f68028

Browse files
authored
fix(pytest): call stop for all instances even if stop raise exception (#4339)
Signed-off-by: adi_holden <adi@dragonflydb.io>
1 parent 682a3f6 commit 3f68028

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/dragonfly/instance.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,19 @@ def start_all(self, instances: List[DflyInstance]):
453453

454454
async def stop_all(self):
455455
"""Stop all launched instances."""
456+
exceptions = [] # To collect exceptions
456457
for instance in self.instances:
457458
await instance.close_clients()
458-
instance.stop()
459+
try:
460+
instance.stop()
461+
except Exception as e:
462+
exceptions.append(e) # Collect the exception
463+
if exceptions:
464+
first_exception = exceptions[0]
465+
raise Exception(
466+
f"One or more errors occurred while stopping instances. "
467+
f"First exception: {first_exception}"
468+
) from first_exception
459469

460470
def __repr__(self) -> str:
461471
return f"Factory({self.args})"

0 commit comments

Comments
 (0)