Skip to content

Commit 17765ca

Browse files
committed
Fix EmailNotification scheduler setup
- Ensured the scheduler is properly initialised in `EmailNotification` - Fixed incorrect instantiation of docstring example `email_notification_2` which previously returned a config instead of an `EmailNotification` instance. Signed-off-by: cyiallou - Costas <[email protected]>
1 parent aa1a99a commit 17765ca

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616

1717
- Updated the Solar Maintenance notebook to fix the expected environment variable name for the reporting server url.
1818
- Fixed a bug in the notification `Scheduler` where tasks could overrun the configured duration due to imprecise sleep and stop logic. The scheduler now correctly tracks elapsed time, respects task execution duration, and stops reliably after the intended interval.
19+
- Fixed an issue where `EmailNotification` did not properly initialise its scheduler. Also fixed an example in the docstring.

src/frequenz/lib/notebooks/notification_service.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
5050
# Create notification objects
5151
email_notification = EmailNotification(config=email_config)
52-
email_notification_2 = EmailConfig.from_dict(email_config_dict)
52+
email_notification_2 = EmailNotification(EmailConfig.from_dict(email_config_dict))
5353
5454
# Send one-off notification
5555
email_notification.send()
@@ -556,6 +556,12 @@ def __init__(self, config: EmailConfig) -> None:
556556
"""
557557
super().__init__()
558558
self._config: EmailConfig = config
559+
if self._config.scheduler:
560+
_log.debug(
561+
"EmailNotification configured with scheduler: %s",
562+
self._config.scheduler,
563+
)
564+
self._scheduler = Scheduler(config=self._config.scheduler)
559565

560566
def send(self) -> None:
561567
"""Send the email notification."""

0 commit comments

Comments
 (0)