Skip to content

Commit c9f3119

Browse files
committed
Document when resent_latest is safe to use in Broadcast channels
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent a858079 commit c9f3119

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/frequenz/channels/_broadcast.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,35 @@ def __init__(self, name: str, resend_latest: bool = False) -> None:
7575
"""Create a Broadcast channel.
7676
7777
Args:
78-
name: A name for the broadcast channel, typically based on the type
79-
of data sent through it. Used to identify the channel in the
80-
logs.
78+
name: A name for the broadcast channel, typically based on the type of data
79+
sent through it. Used to identify the channel in the logs.
8180
resend_latest: When True, every time a new receiver is created with
82-
`new_receiver`, it will automatically get sent the latest value
83-
on the channel. This allows new receivers on slow streams to
84-
get the latest value as soon as they are created, without having
85-
to wait for the next message on the channel to arrive.
81+
`new_receiver`, it will automatically get sent the latest value on the
82+
channel. This allows new receivers on slow streams to get the latest
83+
value as soon as they are created, without having to wait for the next
84+
message on the channel to arrive. It is safe to be set in
85+
data/reporting channels, but is not recommended for use in channels that
86+
stream control instructions.
8687
"""
8788
self._name: str = name
8889
"""The name of the broadcast channel.
8990
9091
Only used for debugging purposes.
9192
"""
9293

93-
self.resend_latest = resend_latest
94-
"""Whether to resend the latest value to new receivers."""
94+
self.resend_latest: bool = resend_latest
95+
"""Whether to resend the latest value to new receivers.
96+
97+
It is `False` by default.
98+
99+
When `True`, every time a new receiver is created with `new_receiver`, it will
100+
automatically get sent the latest value on the channel. This allows new
101+
receivers on slow streams to get the latest value as soon as they are created,
102+
without having to wait for the next message on the channel to arrive.
103+
104+
It is safe to be set in data/reporting channels, but is not recommended for use
105+
in channels that stream control instructions.
106+
"""
95107

96108
self._recv_cv: Condition = Condition()
97109
"""The condition to wait for data in the channel's buffer."""

0 commit comments

Comments
 (0)