Skip to content

Commit 2d88269

Browse files
committed
Add parameter autostart to Dispatcher() service
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 341f852 commit 2d88269

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This release introduces a more flexible and powerful mechanism for managing disp
66

77
## Upgrading
88

9+
* `Dispatcher.__init__` has a new optional parameter `autostart`, which defaults to `True`. If set to `False`, the dispatcher will not start automatically.
910
* `Dispatcher.start` is no longer `async`. Remove `await` when calling it.
1011
* Two properties have been replaced by methods that require a type as parameter.
1112
* `Dispatcher.lifecycle_events` has been replaced by the method `Dispatcher.new_lifecycle_events_receiver(self, dispatch_type: str)`.

src/frequenz/dispatch/_dispatcher.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,15 @@ def __init__(
176176
microgrid_id: int,
177177
server_url: str,
178178
key: str,
179+
autostart: bool = True,
179180
):
180181
"""Initialize the dispatcher.
181182
182183
Args:
183184
microgrid_id: The microgrid id.
184185
server_url: The URL of the dispatch service.
185186
key: The key to access the service.
187+
autostart: Whether to start the dispatcher service immediately.
186188
"""
187189
super().__init__()
188190

@@ -195,6 +197,9 @@ def __init__(
195197
self._empty_event = Event()
196198
self._empty_event.set()
197199

200+
if autostart:
201+
self.start()
202+
198203
@override
199204
def start(self) -> None:
200205
"""Start the local dispatch service."""

0 commit comments

Comments
 (0)