Make hist shm token optional to allow for FSPs

samplerd_service
Tyler Goodlet 2022-11-24 13:29:37 -05:00
parent eacd44dd65
commit 7ec88f8cac
1 changed files with 14 additions and 6 deletions

View File

@ -74,9 +74,12 @@ class Flume(Struct):
''' '''
symbol: Symbol symbol: Symbol
first_quote: dict first_quote: dict
_hist_shm_token: _Token
_rt_shm_token: _Token _rt_shm_token: _Token
# optional since some data flows won't have a "downsampled" history
# buffer/stream (eg. FSPs).
_hist_shm_token: _Token | None = None
# private shm refs loaded dynamically from tokens # private shm refs loaded dynamically from tokens
_hist_shm: ShmArray | None = None _hist_shm: ShmArray | None = None
_rt_shm: ShmArray | None = None _rt_shm: ShmArray | None = None
@ -104,7 +107,14 @@ class Flume(Struct):
@property @property
def hist_shm(self) -> ShmArray: def hist_shm(self) -> ShmArray:
if self._hist_shm is None: if self._hist_shm_token is None:
raise RuntimeError(
'No shm token has been set for the history buffer?'
)
if (
self._hist_shm is None
):
self._hist_shm = attach_shm_array( self._hist_shm = attach_shm_array(
token=self._hist_shm_token, token=self._hist_shm_token,
readonly=True, readonly=True,
@ -288,16 +298,14 @@ class Flume(Struct):
# get far-side x-indices plot view # get far-side x-indices plot view
vr = plot.viewRect() vr = plot.viewRect()
l = vr.left()
r = vr.right()
( (
abs_slc, abs_slc,
buf_slc, buf_slc,
iv_arr, iv_arr,
) = self.slice_from_time( ) = self.slice_from_time(
start_t=l, start_t=vr.left(),
stop_t=r, stop_t=vr.right(),
timeframe_s=timeframe_s, timeframe_s=timeframe_s,
return_data=True, return_data=True,
) )