Skip to content

Commit 9c1a5b2

Browse files
committed
Add exception-recovery for more long-running functions
These appear to be the only remaining long-running functions that don't have their own exception handling. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 835eb82 commit 9c1a5b2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/frequenz/sdk/microgrid/_data_sourcing/microgrid_api_source.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
MeterData,
1919
)
2020

21+
from ..._internal._asyncio import run_forever
2122
from ..._internal._channels import ChannelRegistry
2223
from ...microgrid import connection_manager
2324
from ...timeseries import Sample
@@ -460,7 +461,7 @@ async def _update_streams(
460461
self.comp_data_tasks[comp_id].cancel()
461462

462463
self.comp_data_tasks[comp_id] = asyncio.create_task(
463-
self._handle_data_stream(comp_id, category)
464+
run_forever(lambda: self._handle_data_stream(comp_id, category))
464465
)
465466

466467
async def add_metric(self, request: ComponentMetricRequest) -> None:

src/frequenz/sdk/microgrid/_power_managing/_power_managing_actor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from frequenz.client.microgrid import ComponentCategory, ComponentType, InverterType
1616
from typing_extensions import override
1717

18+
from ..._internal._asyncio import run_forever
1819
from ..._internal._channels import ChannelRegistry
1920
from ...actor import Actor
2021
from ...timeseries import Power
@@ -194,7 +195,7 @@ def _add_system_bounds_tracker(self, component_ids: frozenset[int]) -> None:
194195

195196
# Start the bounds tracker, for ongoing updates.
196197
self._bound_tracker_tasks[component_ids] = asyncio.create_task(
197-
self._bounds_tracker(component_ids, bounds_receiver)
198+
run_forever(lambda: self._bounds_tracker(component_ids, bounds_receiver))
198199
)
199200

200201
def _calculate_shifted_bounds(

0 commit comments

Comments
 (0)