Skip to content

Commit b5fee0b

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

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/frequenz/channels/_receiver.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@
123123
# If we get here, the receiver was stopped
124124
```
125125
126+
# Closing receivers
127+
128+
When a particular stream of data is no-longer required, it is a good practice to close
129+
the receiver to free up resources. This is especially important in applications that are
130+
repeatedly creating new receivers. The
131+
[`Receiver.close()`][frequenz.channels.Receiver.close] method can be used for this
132+
purpose.
133+
134+
After `close()` is called, we can still receive messages that are in the receiver's
135+
buffer, but as soon as the receiver's buffer has been drained, trying to receive further
136+
messages from a *closed* receiver will raise a
137+
[`ReceiverStoppedError`][frequenz.channels.ReceiverStoppedError].
138+
126139
# Advanced Usage
127140
128141
!!! Warning inline end

0 commit comments

Comments
 (0)