Repository navigation
Conversation
`ContinuationCapable` and the outcome enum used with it sat in `_actor_dispatcher.py`, while everything else about continuations already lives in `_continuation.py`. Moving them puts the whole opt-in feature in one module, and leaves room in `_actor_dispatcher.py`, which is close to the line limit its own checks enforce. This is a move and nothing else. The classes are unchanged, and `ContinuationCapable` is still exported under the same public name. Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
`ActorDispatcher` only stopped an actor when a stop event for its dispatch arrived. Stopping the actor dispatcher itself left every actor it had started running, and nothing else can stop them: the actor dispatcher created them and owns the channels they get their dispatch updates from. So an actor kept acting on its dispatch until the process ended. The actors are now stopped, and their update channels closed, whenever the actor dispatcher's own task ends, whether it was cancelled or its running status receiver was closed. Every actor is stopped on its own, and closing a channel is a step of its own too, so an actor that fails to stop can neither leave the others running nor keep any channel open. A cancellation in the middle of all that does not end it either: the stops that are left still run, and the cancellation is raised once they are done. This also covers stopping a single actor on a dispatch stop event, where the actor is already out of the dispatcher's bookkeeping and nothing else could reach its channel any more. A failure cannot be raised while the service is stopping, because that would replace the cancellation that asked it to stop. It is kept and reported by `wait()` instead, so it also reaches a caller that only ever uses `stop()`. Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
`Dispatcher.cancel()` cancelled the actor dispatchers it manages, but it never set the event that `wait()` blocks on, and it never removed the managed types from its list. The first `stop()` still returned, because waiting for the cancelled background service raises and cuts the wait short. Everything after it blocked forever though: a second `stop()`, `wait()`, and awaiting the dispatcher. The stopped types were also still reported as managed, and the actor dispatchers were only asked to stop, never waited for, so the actors they had started were left running. `cancel()` now sets the event, and `wait()` stops and waits for whatever managed types are left before dropping them. Each type is stopped on its own, so one type that fails to stop cannot leave another one running, and the failures do not replace the error that is already on its way out, which is normally the cancellation itself. A task that is already being cancelled is never cancelled again, neither by `cancel()`, nor by `wait()`, nor by `stop_managing()`. A second cancellation interrupts the cleanup that the first one started, which used to leave a type's actors half stopped, and in the case of `stop_managing()` left them running with nothing able to reach them any more. Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
The client creates one stream helper per microgrid and keeps it in a list of its own. Disconnecting the client only closes the gRPC channel, so the helper's task stayed alive and kept calling the dispatch API again and again after the scheduler was already gone. The client has no public way to stop it, so the scheduler now stops the stream it asked for itself. The stream receiver is closed first, so it is not left reading from a channel that is closed under it. Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
Marenz
requested review from
stefan-brus-frequenz
and removed request for
a team
November 30, 2026 11:09
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stopping the dispatcher or the
ActorDispatcherleft things running:ActorDispatcherkept running, with nobody left to stop them.Each stop now runs on its own, so one failure or a cancellation cannot skip the rest. Tests are in
tests/test_shutdown.py.