Skip to content

Commit a6e5a7b

Browse files
Log reason for actor and backgroud service stop
`msg` argument is not logged. This PR adds info log to actor and debug logs to background service. Signed-off-by: Elzbieta Kotulska <[email protected]>
1 parent affb3a3 commit a6e5a7b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/frequenz/sdk/actor/_actor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,6 @@ def cancel(self, msg: str | None = None) -> None:
144144
Args:
145145
msg: The message to be passed to the tasks being cancelled.
146146
"""
147+
_logger.info("Actor %s cancelled, reason: %s", self.name, msg)
147148
self._is_cancelled = True
148149
return super().cancel(msg)

src/frequenz/sdk/actor/_background_service.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
import abc
77
import asyncio
88
import collections.abc
9+
import logging
910
from types import TracebackType
1011
from typing import Any, Self
1112

13+
_logger = logging.getLogger(__name__)
14+
1215

1316
class BackgroundService(abc.ABC):
1417
"""A background service that can be started and stopped.
@@ -167,6 +170,9 @@ def cancel(self, msg: str | None = None) -> None:
167170
Args:
168171
msg: The message to be passed to the tasks being cancelled.
169172
"""
173+
174+
_logger.debug("Service %s cancelled, reason: %s", self.name, msg)
175+
170176
for task in self._tasks:
171177
task.cancel(msg)
172178

0 commit comments

Comments
 (0)