Skip to content

Commit 08662b9

Browse files
committed
Close receiver when stopping LatestValueCache
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
1 parent 9797c28 commit 08662b9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/frequenz/channels/_latest_value_cache.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class LatestValueCache(typing.Generic[T_co]):
5353
5454
It provides a way to look up the latest value in a stream without any delay,
5555
as long as there has been one value received.
56+
57+
Takes ownership of the receiver. When the cache is stopped, the receiver
58+
will be closed.
5659
"""
5760

5861
def __init__(
@@ -108,7 +111,8 @@ async def _run(self) -> None:
108111
self._latest_value = value
109112

110113
async def stop(self) -> None:
111-
"""Stop the cache."""
114+
"""Stop the cache and close the owned receiver."""
115+
self._receiver.close()
112116
if not self._task.done():
113117
self._task.cancel()
114118
try:

0 commit comments

Comments
 (0)