Skip to content

Commit cd70b3a

Browse files
committed
Explain the Receiver.close() method in the user guide
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent b27175a commit cd70b3a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/frequenz/channels/_receiver.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@
123123
# If we get here, the receiver was stopped
124124
```
125125
126+
# Closing receivers
127+
128+
To deal with situations where data from a particular stream is no-longer required,
129+
receivers offer a [`close()`][frequenz.channels.Receiver.close] method that can be used
130+
to stop it from receiving new messages.
131+
132+
After `close()` is called, we can still receive messages that are in the receiver's
133+
buffer, but as soon as the receiver's buffer has been drained, trying to receive further
134+
messages from a *closed* receiver will raise a
135+
[`ReceiverStoppedError`][frequenz.channels.ReceiverStoppedError].
136+
126137
# Advanced Usage
127138
128139
!!! Warning inline end

0 commit comments

Comments
 (0)