Skip to content

Commit 23953ad

Browse files
Debug exception do not inherit from BaseException error
1 parent e3c7dc0 commit 23953ad

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/frequenz/sdk/timeseries/formula_engine/_formula_evaluator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ async def stop(self) -> None:
9494
asyncio.create_task(cancel_and_await(task))
9595
for task in self._pending_fetch_tasks
9696
]
97+
# Here fetch_next task should receive CancelError. But instead
98+
# receiver returns error that do not inherit from BaseException.
99+
print("!!! HERE DEBUG: Stopping fetch tasks")
97100
await asyncio.wait(tasks_to_cancel, return_when=asyncio.ALL_COMPLETED)
101+
print("!! HERE DEBUG: Stopped fetch tasks")
98102
self._pending_fetch_tasks = []
99103

100104
async def apply(self) -> Sample[QuantityT]:

src/frequenz/sdk/timeseries/formula_engine/_formula_steps.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,15 @@ async def _fetch_next(self) -> Sample[QuantityT] | None:
529529
try:
530530
next_value = await self._stream.receive()
531531
except ReceiverError[Any] as err:
532-
_logger.error("Failed to fetch next value from %s: %s", self._name, err)
532+
# I tried to catch
533+
# 1. BaseException - it showed that an error is here, but error was empty
534+
# 2. Exception - then nothings happen, everything works and this log is not printed
535+
_logger.error(
536+
"Failed to fetch next value from %s: %s, END", self._name, err
537+
)
538+
# Return because otherwise we start fallback formula.
539+
# This should be improved removed after we know what is wrong with this exception
540+
return
533541
else:
534542
if self._is_value_valid(next_value.value):
535543
return next_value

0 commit comments

Comments
 (0)