Repository navigation
Description
What's needed?
Pipe is used by our own projects and is ready to leave experimental. Unlike WithPrevious and NopReceiver (#577), it can't just move with a deprecated alias: #565 changes how it treats its endpoints, so the stable Pipe behaves differently from the experimental one.
What changes, compared to the experimental Pipe:
- When its receiver stops, the new
Pipecloses its sender. The old one stops and leaves the sender open. - When a send fails with a
SenderError, the newPipelogs it and closes both its sender and its receiver by default. The old one lets the exception end its task and leaves both open. - With
close_pipe_on_send_error=False, the newPipedrops the message that failed and keeps forwarding the next ones. This doesn't bring back the old behavior. stop()leaves both ends open in both.
Proposed solution
In v2.0.0 only, on v2.x.x:
- Move the implementation Add has_receivers/has_senders and fix BroadcastChannel auto-close #565 left in
experimental/_pipe.pyto a new top-levelfrequenz.channels.Pipe. - Restore
frequenz.channels.experimental.Pipeto the v1 implementation, as a separate class (not an alias of the new one), and mark it@deprecated(since="v2.0.0"). Its warning and itsDeprecated:notice should explain the behavior differences above, not only the new import, so users check how they close their endpoints before switching. It is removed in v3.0.0 (Breaking changes for v3.0 #581). - When a send fails with a
TransientSenderError(Have a way to avoid dropping messages in broadcast channels #20:SenderWouldBlockError, and the error for a channel without receivers, which Add has_receivers/has_senders and fix BroadcastChannel auto-close #565 namedNoReceiversErrorand v2.0.0 renames toSenderHasNoReceiversError), the newPipelogs it, drops the message and keeps forwarding, as the channel can still be used. It closes both ends only on otherSenderErrors, soclose_pipe_on_send_erroronly applies to those. Retrying instead of dropping is LetPiperetry sends that fail with aTransientSenderError#594. - Document the new
Pipein the user guide, including who owns and closes each end. - Test both: the old one keeps its behavior and warns, the new one doesn't warn.
v1 doesn't change: the experimental Pipe stays as it is and isn't deprecated there.
Additional context
This replaces the earlier plan to add the new Pipe in v1.13.0. That can't give users the same behavior on both majors, because a BroadcastChannel without receivers closes itself on a send in v1 and stays open in v2; see #589 (comment). Keeping the old Pipe in v2 lets projects that use it support both v1 and v2, and switch to the new one when they require v2.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
[-]Add the new `Pipe` to `frequenz.channels` and deprecate the experimental one[/-][+]Add the new `Pipe` to `frequenz.channels` in v2 and deprecate the experimental one[/+]Piperetry sends that fail with aTransientSenderError#594NoReceiversErroraTransientSenderErrorand rename it toSenderHasNoReceiversError#599Add `TransientSenderError` and rename `NoReceiversError` to `SenderHa…
Keep the experimental `Pipe` backwards compatible (#611)