mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-03 06:08:15 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user