Repository navigation
Conversation
`SenderError` doesn't tell a caller whether the sender can still be used. Code that keeps sending, like the new `Pipe` in the next commit, has to tell the errors that only drop one message apart from the ones that make the sender or its channel unusable. `TransientSenderError` is a new `SenderError` for the first kind: the message wasn't sent, but the sender and its channel can still be used. It is a base class only, no sender in this library raises it yet, but custom senders can, and the `Pipe` handles it. The class and its docstring are the ones that `v2.x.x` already has, so the next merge of `v1.x.x` into `v2.x.x` doesn't conflict on them. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
`frequenz.channels.experimental.Pipe` leaves its sender and its receiver open when it stops by itself, and a failed send ends its task with an exception nobody reads. Changing that in place would silently change what existing users get, so the new behavior goes in a new top-level `Pipe`, and the experimental one stays as it is. The new `Pipe` closes its sender when its receiver stops. When sending fails with a `TransientSenderError`, the sender and its channel can still be used, so it logs a warning, drops the message and keeps forwarding. Any other `SenderError` is logged with its traceback, and the pipe closes both ends and stops, unless `close_pipe_on_send_error=False`, which drops the message and keeps going. Its docstring says who owns and closes each end. The class is the one already in `v2.x.x`, without its handling of `SenderHasNoReceiversError`, which only exists in v2, so the next merge of `v1.x.x` into `v2.x.x` conflicts as little as possible. The docstring explains what that means in v1: a send without receivers closes a `BroadcastChannel` and raises a `SenderError`, so the pipe stops and closes its ends by default, while a `Broadcast` with the default `auto_close=False` just drops the message and the pipe keeps going. The tests are the ones of `v2.x.x`, with new ones for the v1 cases above, and the class has a page in the user guide. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
The new top-level `Pipe` replaces `frequenz.channels.experimental.Pipe`, so deprecate the experimental one in v1.13.0, and remove it in v3.0.0. It is not an alias of the new `Pipe`, as the two don't behave the same and an alias would change the behavior of existing code. The v1 implementation stays as it is, so code that still uses it keeps working, and code that has to support both v1 and v2 can use the new `Pipe`. The new `Pipe` closes its sender when its receiver stops, and both ends when sending fails, while the old one leaves them open. Users should check how they close their ends before they switch, so the warning says so, and not only which class to use. The notice has a short version, and the docstring body lists the differences, as the deprecations guide asks. The class, its warning and its docstring are the ones of `v2.x.x`, except for the version in the notice and the parts about `SenderHasNoReceiversError`, which doesn't exist in v1, so the next merge of `v1.x.x` into `v2.x.x` conflicts as little as possible. The tests check that the old `Pipe` keeps its behavior and warns. In v1 a send without receivers closes a `BroadcastChannel` and raises a plain `SenderError`, which still ends the task of the old `Pipe`. The tests and the docstring example use `BroadcastChannel` instead of the deprecated `Broadcast`. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Add a migration entry for the deprecation of `frequenz.channels.experimental.Pipe`, which says what to use instead and lists how the two pipes close their ends differently, with the wording of its deprecation warning. Add New Features entries for `Pipe` and `TransientSenderError`, which also say what a send without receivers does in v1 and in v2.0.0. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
llucax
force-pushed
the
top-level-pipe-v1
branch
from
November 16, 2026 13:49
34be094 to
b78f947
Compare
Contributor
Author
|
Closing: the new top-level |
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.
This adds the new
frequenz.channels.Pipeto v1, so projects can use it withfrequenz-channels >= 1.13.0, < 3. It is the samePipeas the one in #611 (v2), without the case that only exists in v2. v1.13.0 waits for this PR.frequenz.channels.experimental.Pipekeeps its v1 behavior, but it is deprecated in v1.13.0 and will be removed in v3.0.0, with the same warning as in #611.There are four commits:
Add TransientSenderError: the classv2.x.xhas, with its export and test, so a pipe can tell the errors that only drop one message from the ones that make the sender unusable. Nothing in v1 raises it, but custom senders can, and thePipehandles it. Its docstring doesn't say that any sender raises it.Add the new Pipe to frequenz.channels:_pipe.py, its export, a user guide page and the tests, as in Keep the experimentalPipebackwards compatible #611. The pipe closes its sender when its receiver stops. When sending fails with aTransientSenderError, it logs a warning, drops the message and keeps forwarding. Any otherSenderErrormakes it close both ends and stop, unlessclose_pipe_on_send_error=False, which drops the message and keeps going.Deprecate experimental.Pipe:@deprecatedwith a warning that explains the closing differences, and aDeprecated:notice since v1.13.0. The class, warning and docstring are the ones of Keep the experimentalPipebackwards compatible #611, without the parts aboutSenderHasNoReceiversError. The tests check that it keeps its behavior and warns.Update the release notes for the new Pipe: a migration entry for the deprecation, and New Features entries forPipeandTransientSenderError.To stay close to v2,
_pipe.pyonly differs from #611's in the cases that don't exist in v1: there is noSenderHasNoReceiversError, so everyTransientSenderErroris logged as a warning, and the docstring explains what v1 does with a send without receivers. ABroadcastChannelcloses itself and raises a plainSenderError, so the pipe stops and closes its ends by default; aBroadcastwith the defaultauto_close=Falsedrops the message and the pipe keeps going. In v2, aBroadcastChannelwithout receivers stays open, so the pipe keeps going.The tests for
Pipeare the ones of #611, adapted to v1 (nohas_receiversorhas_senders), plus tests for aBroadcastthat keeps going and aBroadcastChannelwithout receivers that stops the pipe.Part of #583, which is closed by the v2 work (#611), so this doesn't close it.