From 9b4bfb6264c46e91faaacae8297679af09d3b2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20V=C3=B6lcker?= Date: Mon, 16 Mar 2026 14:24:03 +0100 Subject: [PATCH 1/2] Override Formula.cancel and .wait rather than .stop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Simon Völcker --- .../sdk/timeseries/formulas/_formula.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/frequenz/sdk/timeseries/formulas/_formula.py b/src/frequenz/sdk/timeseries/formulas/_formula.py index e1e16a2f9..67930ac9a 100644 --- a/src/frequenz/sdk/timeseries/formulas/_formula.py +++ b/src/frequenz/sdk/timeseries/formulas/_formula.py @@ -98,12 +98,20 @@ def start(self) -> None: self._evaluator.start() @override - async def stop(self, msg: str | None = None) -> None: - """Stop the formula evaluator.""" - await BackgroundService.stop(self, msg) + def cancel(self, msg: str | None = None) -> None: + """Cancel the formula evaluator.""" + super().cancel(msg) for sub_formula in self._sub_formulas: - await sub_formula.stop(msg) - await self._evaluator.stop(msg) + sub_formula.cancel(msg) + self._evaluator.cancel(msg) + + @override + async def wait(self) -> None: + """Wait for the formula evaluator to finish.""" + await super().wait() + for sub_formula in self._sub_formulas: + await sub_formula.wait() + await self._evaluator.wait() def __add__( self, other: FormulaBuilder[QuantityT] | QuantityT | Formula[QuantityT] From 51218358db978440e8513a71ea4de4a448b3f00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20V=C3=B6lcker?= Date: Mon, 16 Mar 2026 14:31:19 +0100 Subject: [PATCH 2/2] Update release notes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Simon Völcker --- RELEASE_NOTES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d0f4b3108..d36ca7298 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -17,3 +17,5 @@ - Improved formula validation: Consistent error messages for invalid formulas and conventional span semantics. - This fixes a rare power distributor bug where some battery inverters becoming unreachable because of network outages would lead to excess power values getting set. This is fixed by measuring the power of the unreachable inverters through their fallback meters and excluding that power from what is distributed to the other inverters. + +- Fixed stopping formulas: It will now also stop the evaluator and sub-formulas correctly.