Skip to content

Commit 1796206

Browse files
Log reason for backgroud service stop
Log `msg` argument to simplify debugging. Signed-off-by: Elzbieta Kotulska <[email protected]>
1 parent a2a9066 commit 1796206

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/frequenz/sdk/actor/_background_service.py

Lines changed: 5 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,8 @@ def cancel(self, msg: str | None = None) -> None:
167170
Args:
168171
msg: The message to be passed to the tasks being cancelled.
169172
"""
173+
_logger.info("Service %s cancelled, reason: %s", self.name, msg)
174+
170175
for task in self._tasks:
171176
task.cancel(msg)
172177

0 commit comments

Comments
 (0)