File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 66import time
77import zipapp
88from concurrent .futures import ThreadPoolExecutor , as_completed
9+ from multiprocessing import Pool
910from pathlib import Path
1011from typing import Optional
1112
@@ -112,10 +113,18 @@ def stop_scenario(scenario_name):
112113
113114
114115def stop_all_scenarios (scenarios ):
115- """Stop all active scenarios using Helm"""
116- with console .status ("[bold yellow]Stopping all scenarios...[/bold yellow]" ):
117- for scenario in scenarios :
118- stop_scenario (scenario )
116+ """Stop all active scenarios in parallel using multiprocessing"""
117+
118+ def stop_single (scenario ):
119+ stop_scenario (scenario )
120+ return f"Stopped scenario: { scenario } "
121+
122+ with console .status ("[bold yellow]Stopping all scenarios...[/bold yellow]" ), Pool () as pool :
123+ results = pool .map (stop_single , scenarios )
124+
125+ for result in results :
126+ console .print (f"[bold green]{ result } [/bold green]" )
127+
119128 console .print ("[bold green]All scenarios have been stopped.[/bold green]" )
120129
121130
You can’t perform that action at this time.
0 commit comments