File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 6
6
import time
7
7
import zipapp
8
8
from concurrent .futures import ThreadPoolExecutor , as_completed
9
+ from multiprocessing import Pool
9
10
from pathlib import Path
10
11
from typing import Optional
11
12
@@ -112,10 +113,18 @@ def stop_scenario(scenario_name):
112
113
113
114
114
115
def 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
+
119
128
console .print ("[bold green]All scenarios have been stopped.[/bold green]" )
120
129
121
130
You can’t perform that action at this time.
0 commit comments