Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Explain the Receiver.close() method in the user guide #368

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/frequenz/channels/_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@
# If we get here, the receiver was stopped
```

# Closing receivers

When a particular stream of data is no-longer required, it is a good practice to close
the receiver to free up resources. This is especially important in applications that are
repeatedly creating new receivers. The
[`Receiver.close()`][frequenz.channels.Receiver.close] method can be used for this
purpose.

After `close()` is called, we can still receive messages that are in the receiver's
buffer, but as soon as the receiver's buffer has been drained, trying to receive further
messages from a *closed* receiver will raise a
[`ReceiverStoppedError`][frequenz.channels.ReceiverStoppedError].

# Advanced Usage

!!! Warning inline end
Expand Down
Loading