Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
+ The class is now immutable.
+ The constructor now accepts only keyword arguments.

- The Actor class now generates a name with the class name and the instance id.

## New Features

- `LoggingConfigUpdatingActor`
Expand Down
8 changes: 5 additions & 3 deletions src/frequenz/sdk/actor/_background_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ def __init__(self, *, name: str | None = None) -> None:
"""Initialize this BackgroundService.

Args:
name: The name of this background service. If `None`, `str(id(self))` will
be used. This is used mostly for debugging purposes.
name: The name of this background service. If `None`, id with the
class name will be generated. This is used mostly for debugging purposes.
"""
self._name: str = str(id(self)) if name is None else name
self._name: str = (
f"{self.__class__.__name__}_{id(self)}" if name is None else name
)
self._tasks: set[asyncio.Task[Any]] = set()

@abc.abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/actor/test_background_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def nop() -> None:
async def test_construction_defaults() -> None:
"""Test the construction of a background service with default arguments."""
fake_service = FakeService()
assert fake_service.name == str(id(fake_service))
assert fake_service.name.startswith("FakeService_")
assert fake_service.tasks == set()
assert fake_service.is_running is False
assert str(fake_service) == f"FakeService[{fake_service.name}]"
Expand Down
Loading