Skip to content

Keep the experimental Pipe backwards compatible - #611

Merged
llucax merged 3 commits into
frequenz-floss:v2.x.xfrom
llucax:top-level-pipe
Nov 23, 2026
Merged

llucax merged 3 commits into
frequenz-floss:v2.x.xfrom
llucax:top-level-pipe

Conversation

@llucax

@llucax llucax commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

This adds the new frequenz.channels.Pipe and restores frequenz.channels.experimental.Pipe to its v1 behavior, deprecated and removed in v3.0.0.

It has three commits:

  1. Add the new Pipe to frequenz.channels: the Pipe PR 565 left in experimental/_pipe.py, moved to the top level, with one change: when a send fails with a TransientSenderError (for now only SenderHasNoReceiversError), the pipe logs it, drops the message and keeps forwarding, as the sender and its channel can still be used. close_pipe_on_send_error only applies to the other SenderErrors. Its docstring says who owns and closes each end, and it has a page in the user guide.
  2. Restore experimental.Pipe and deprecate it: the v1 implementation, as a separate class marked @deprecated, removed in v3.0.0. Its warning and its notice say how the new Pipe closes its ends differently, so users check that before they switch. The tests check that it keeps its v1 behavior and warns, and that the new one doesn't warn.
  3. Update the release notes for the new Pipe: PR 565's entries described the behavior change of the experimental Pipe in place. They are replaced by one migration entry for the deprecation, and an entry for the new Pipe in New Features.

The deprecation warning is: frequenz.channels.experimental.Pipe is deprecated and will be removed in v3.0.0. Use frequenz.channels.Pipe instead, but check how your code closes its sender and receiver first: the new one closes its sender when its receiver stops, and both ends when sending fails, while this one leaves them open.

A dropped message is logged at debug level for a SenderHasNoReceiversError, since a channel without receivers is common and every message would log, and as a warning for any other TransientSenderError. Before, a SenderHasNoReceiversError was a warning when the pipe closed, and debug with close_pipe_on_send_error=False.

Closes #583.

@llucax llucax added this to the v2.0.0 milestone Nov 13, 2026
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:channels Affects channels implementation part:synchronization Affects the synchronization of multiple sources (`select`, `merge`) part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) part:utilities Affects the utility receivers (`Timer`, `Event`, `FileWatcher`) part:experimental Affects the experimental package labels Nov 13, 2026
@llucax
llucax force-pushed the top-level-pipe branch 2 times, most recently from 636cbe1 to 8bb767e Compare November 20, 2026 09:44
@llucax llucax changed the title Add the new Pipe to frequenz.channels and deprecate the experimental one Move the new Pipe to frequenz.channels and deprecate the old one Nov 20, 2026
@llucax llucax changed the title Move the new Pipe to frequenz.channels and deprecate the old one Keep the experimental Pipe backwards compatible Nov 20, 2026
@llucax
llucax force-pushed the top-level-pipe branch 2 times, most recently from 20c375d to 3a2f87f Compare November 20, 2026 10:58
@llucax
llucax marked this pull request as ready for review November 20, 2026 10:59
@llucax
llucax requested a review from a team as a code owner November 20, 2026 10:59
@llucax
llucax requested review from florian-wagner-frequenz and removed request for a team November 20, 2026 10:59
@llucax llucax self-assigned this Nov 20, 2026
@llucax llucax removed this from the v2.0.0 milestone Nov 20, 2026
@llucax
llucax requested review from shsms and an adaptive review from Copilot November 20, 2026 10:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The pipe’s stop logic can swallow caller cancellation and interrupt endpoint cleanup, leaving senders open and downstream consumers waiting indefinitely.

4 open issues
What changed in this PR

This PR promotes Pipe to the public channel API while preserving v1 behavior for existing experimental users. Separate implementations let callers migrate deliberately to the new endpoint-closing behavior, addressing #583.

Changes:

  • Export a stable Pipe that handles endpoint cleanup and continues forwarding after transient send errors.
  • Restore the experimental implementation’s v1 behavior and deprecate it for removal in v3.0.0.
  • Add tests, user-guide documentation, and release notes explaining the migration.
File Description
tests/​test_pipe.py Test stable forwarding, error handling, and endpoint lifecycle behavior.
tests/​experimental/​test_pipe.py Test legacy behavior and deprecation warnings.
src/​frequenz/​channels/​experimental/​_pipe.py Restore the legacy implementation and add migration guidance.
src/​frequenz/​channels/​_pipe.py Add the stable implementation with documented endpoint ownership.
src/​frequenz/​channels/​__init__.py Export and list the public Pipe utility.
RELEASE_NOTES.md Describe the new API and experimental migration path.
docs/​user-guide/​utilities/​pipes.md Add a user-guide page for the stable Pipe.

Review effort: Max (adaptive)

Comment thread src/frequenz/channels/_pipe.py Resolved
Comment thread src/frequenz/channels/_pipe.py Resolved
Comment thread src/frequenz/channels/_pipe.py Resolved
@llucax
llucax force-pushed the top-level-pipe branch 2 times, most recently from 52e5b01 to 31bbac1 Compare November 20, 2026 12:09
`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.  PR 565 changed that behavior in place, which
would silently change what existing users get, so move it to a new
top-level `Pipe` instead.  The experimental `Pipe` goes back to its old
behavior as a separate, deprecated class in the next commit, so both can
be used at the same time.

The new `Pipe` is the one PR 565 left in `experimental/_pipe.py`, with a
change for `TransientSenderError`.  When sending fails with one, for
example a `SenderHasNoReceiversError`, the sender and its channel can
still be used, so the pipe logs it, drops the message and keeps
forwarding.  Before, it closed both ends for a send without receivers.
`close_pipe_on_send_error` now only applies to the other `SenderError`s.
A `SenderHasNoReceiversError` is logged at debug level, as a channel
without receivers is common and every message would log; any other
`TransientSenderError` is logged as a warning.

The docstring says who owns and closes each end, and the class is added
to the user guide.  The tests are the ones for the experimental `Pipe`,
using `BroadcastChannel`, plus new ones for the transient errors.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
PR 565 changed `frequenz.channels.experimental.Pipe` in place, so code
that upgrades to v2 would silently get a pipe that closes its ends and
drops messages.  The previous commit adds that behavior as the top-level
`Pipe`, so restore the experimental one to its v1 implementation, as a
separate class, and deprecate it.  It is removed 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.  Keeping the old
one also lets code that uses it support both v1 and v2, and switch to the
new `Pipe` when it requires v2.

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 tests check that the old `Pipe` keeps its v1 behavior and warns, and
a new one checks that it still stops on a send without receivers, which
the new `Pipe` doesn't.  The example in the docstring uses
`BroadcastChannel` instead of the deprecated `Broadcast`.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
PR 565's entries described the behavior change of `experimental.Pipe`
in place.  That class keeps its v1 behavior and is deprecated now, so
replace them with a single migration entry that lists the differences
with the new `Pipe`, as the deprecations guide asks.

The new `Pipe` is a new feature, with its closing rules.  The entry also
says what it does with a `TransientSenderError`.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax
llucax added this pull request to the merge queue Nov 23, 2026
Merged via the queue into frequenz-floss:v2.x.x with commit e22fdad Nov 23, 2026
9 checks passed
@llucax
llucax deleted the top-level-pipe branch November 23, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:channels Affects channels implementation part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) part:docs Affects the documentation part:experimental Affects the experimental package part:synchronization Affects the synchronization of multiple sources (`select`, `merge`) part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:utilities Affects the utility receivers (`Timer`, `Event`, `FileWatcher`)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the new Pipe to frequenz.channels in v2 and deprecate the experimental one

3 participants