Skip to content

Commit 6cb9030

Browse files
committed
Add a stop method to BatteryPool
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 6be20fc commit 6cb9030

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/frequenz/sdk/timeseries/battery_pool/_battery_pool.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,7 @@ def _system_power_bounds(self) -> ReceiverFetcher[SystemBounds]:
429429
)
430430

431431
return self._battery_pool._active_methods[method_name]
432+
433+
async def stop(self) -> None:
434+
"""Stop all tasks and channels owned by the BatteryPool."""
435+
await self._battery_pool.stop()

tests/timeseries/_formula_engine/test_formula_composition.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ async def test_formula_composition( # pylint: disable=too-many-locals
3636
stack.push_async_callback(logical_meter.stop)
3737

3838
battery_pool = microgrid.battery_pool()
39-
stack.push_async_callback(
40-
battery_pool._battery_pool.stop # pylint: disable=protected-access
41-
)
39+
stack.push_async_callback(battery_pool.stop)
4240

4341
pv_pool = microgrid.pv_pool()
4442
stack.push_async_callback(pv_pool.stop)
@@ -116,9 +114,7 @@ async def test_formula_composition_missing_pv(self, mocker: MockerFixture) -> No
116114
count = 0
117115
async with mockgrid, AsyncExitStack() as stack:
118116
battery_pool = microgrid.battery_pool()
119-
stack.push_async_callback(
120-
battery_pool._battery_pool.stop # pylint: disable=protected-access
121-
)
117+
stack.push_async_callback(battery_pool.stop)
122118

123119
pv_pool = microgrid.pv_pool()
124120
stack.push_async_callback(pv_pool.stop)
@@ -160,9 +156,7 @@ async def test_formula_composition_missing_bat(self, mocker: MockerFixture) -> N
160156
count = 0
161157
async with mockgrid, AsyncExitStack() as stack:
162158
battery_pool = microgrid.battery_pool()
163-
stack.push_async_callback(
164-
battery_pool._battery_pool.stop # pylint: disable=protected-access
165-
)
159+
stack.push_async_callback(battery_pool.stop)
166160

167161
pv_pool = microgrid.pv_pool()
168162
stack.push_async_callback(pv_pool.stop)

0 commit comments

Comments
 (0)