From 92b24334d598cf6710781d48870f33d7912aa692 Mon Sep 17 00:00:00 2001 From: alex-clawd Date: Wed, 13 May 2026 12:36:56 -0700 Subject: [PATCH] fix: move progress.start() into try block and use shared event loop in benchmark command - Move progress.start() inside the try block so the finally clause never calls progress.stop() on an un-started display - Replace asyncio.run() with new_event_loop/run_until_complete/loop.close() pattern, consistent with _test_new_agents and _train_new_agents Co-Authored-By: Claude Sonnet 4.6 --- lib/cli/src/crewai_cli/cli.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/cli/src/crewai_cli/cli.py b/lib/cli/src/crewai_cli/cli.py index a38c4f0d4..38c909de3 100644 --- a/lib/cli/src/crewai_cli/cli.py +++ b/lib/cli/src/crewai_cli/cli.py @@ -1754,13 +1754,15 @@ def benchmark( ) progress = None if verbose else _BenchmarkLiveProgress(console=_con) - if progress: - progress.start() + _loop = asyncio.new_event_loop() + asyncio.set_event_loop(_loop) try: + if progress: + progress.start() with ArtifactsSandbox(): if verbose: with VerboseBenchmarkOutput(): - results_by_model = asyncio.run( + results_by_model = _loop.run_until_complete( run_benchmark( agent_def=agent_path, cases=cases, @@ -1772,7 +1774,7 @@ def benchmark( ) else: with SuppressBenchmarkOutput(): - results_by_model = asyncio.run( + results_by_model = _loop.run_until_complete( run_benchmark( agent_def=agent_path, cases=cases, @@ -1788,6 +1790,7 @@ def benchmark( finally: if progress: progress.stop() + _loop.close() if len(results_by_model) > 1: _con.print()