File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ def __init__(
7575 self ._task : asyncio .Task [None ] = asyncio .create_task (
7676 self ._run (), name = f"LatestValueCache«{ self ._unique_id } »"
7777 )
78+ self ._stopped : bool = False
7879
7980 @property
8081 def unique_id (self ) -> str :
@@ -96,6 +97,8 @@ def get(self) -> T_co:
9697 """
9798 if isinstance (self ._latest_value , _Sentinel ):
9899 raise ValueError ("No value has been received yet." )
100+ if self ._stopped :
101+ raise ValueError ("Cache has been stopped." )
99102 return self ._latest_value
100103
101104 def has_value (self ) -> bool :
@@ -113,6 +116,7 @@ async def _run(self) -> None:
113116 async def stop (self ) -> None :
114117 """Stop the cache and close the owned receiver."""
115118 self ._receiver .close ()
119+ self ._stopped = True
116120 if not self ._task .done ():
117121 self ._task .cancel ()
118122 try :
You can’t perform that action at this time.
0 commit comments