Skip to content

Add the new Pipe to v1 - #612

Closed
llucax wants to merge 4 commits into
frequenz-floss:v1.x.xfrom
llucax:top-level-pipe-v1
Closed

llucax wants to merge 4 commits into
frequenz-floss:v1.x.xfrom
llucax:top-level-pipe-v1

Conversation

@llucax

@llucax llucax commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

This adds the new frequenz.channels.Pipe to v1, so projects can use it with frequenz-channels >= 1.13.0, < 3. It is the same Pipe as the one in #611 (v2), without the case that only exists in v2. v1.13.0 waits for this PR.

frequenz.channels.experimental.Pipe keeps 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:

  1. Add TransientSenderError: the class v2.x.x has, 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 the Pipe handles it. Its docstring doesn't say that any sender raises it.
  2. Add the new Pipe to frequenz.channels: _pipe.py, its export, a user guide page and the tests, as in Keep the experimental Pipe backwards compatible #611. The pipe closes its sender when its receiver stops. When sending fails with a TransientSenderError, it logs a warning, drops the message and keeps forwarding. Any other SenderError makes it close both ends and stop, unless close_pipe_on_send_error=False, which drops the message and keeps going.
  3. Deprecate experimental.Pipe: @deprecated with a warning that explains the closing differences, and a Deprecated: notice since v1.13.0. The class, warning and docstring are the ones of Keep the experimental Pipe backwards compatible #611, without the parts about SenderHasNoReceiversError. The tests check that it keeps its behavior and warns.
  4. Update the release notes for the new Pipe: a migration entry for the deprecation, and New Features entries for Pipe and TransientSenderError.

To stay close to v2, _pipe.py only differs from #611's in the cases that don't exist in v1: there is no SenderHasNoReceiversError, so every TransientSenderError is logged as a warning, and the docstring explains what v1 does with a send without receivers. A BroadcastChannel closes itself and raises a plain SenderError, so the pipe stops and closes its ends by default; a Broadcast with the default auto_close=False drops the message and the pipe keeps going. In v2, a BroadcastChannel without receivers stays open, so the pipe keeps going.

The tests for Pipe are the ones of #611, adapted to v1 (no has_receivers or has_senders), plus tests for a Broadcast that keeps going and a BroadcastChannel without receivers that stops the pipe.

Part of #583, which is closed by the v2 work (#611), so this doesn't close it.

`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>
@llucax llucax added this to the v1.13.0 milestone Nov 16, 2026
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) labels Nov 16, 2026
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

llucax commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the new top-level Pipe stays in v2.0.0 only (#583, #611), and experimental.Pipe isn't deprecated in v1. A BroadcastChannel without receivers closes itself on a send in v1 and stays open in v2, so the same Pipe would behave differently in v1.13.0 and v2.0.0, which we don't want. See #589 (comment).

@llucax llucax closed this Nov 16, 2026
@llucax
llucax deleted the top-level-pipe-v1 branch November 16, 2026 14:00
@llucax llucax modified the milestones: v1.13.0, Dropped Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) part:docs Affects the documentation part:experimental Affects the experimental package part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant