Skip to content

Commit 0ff4d73

Browse files
committed
Fix "stop all" bug. Multiprocessing doesn't like local functions
1 parent 2f365ee commit 0ff4d73

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/warnet/control.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,33 @@ def stop_scenario(scenario_name):
112112
)
113113

114114

115-
def stop_all_scenarios(scenarios):
116-
"""Stop all active scenarios in parallel using multiprocessing"""
115+
def _stop_single(scenario: str) -> str:
116+
"""
117+
Stop a single scenario
118+
119+
Args:
120+
scenario: Name of the scenario to stop
121+
122+
Returns:
123+
str: Message indicating the scenario has been stopped
124+
"""
125+
stop_scenario(scenario)
126+
return f"Stopped scenario: {scenario}"
127+
117128

118-
def stop_single(scenario):
119-
stop_scenario(scenario)
120-
return f"Stopped scenario: {scenario}"
129+
def stop_all_scenarios(scenarios) -> None:
130+
"""
131+
Stop all active scenarios in parallel using multiprocessing
132+
133+
Args:
134+
scenarios: List of scenario names to stop
135+
136+
Returns:
137+
None
138+
"""
121139

122140
with console.status("[bold yellow]Stopping all scenarios...[/bold yellow]"), Pool() as pool:
123-
results = pool.map(stop_single, scenarios)
141+
results = pool.map(_stop_single, scenarios)
124142

125143
for result in results:
126144
console.print(f"[bold green]{result}[/bold green]")

0 commit comments

Comments
 (0)