From 08e8990fe38fe0af168306fd0d0c245e25263f94 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 26 Jul 2023 15:41:04 -0400 Subject: [PATCH] Do single `ShmArray.array` read on zero-time filtering --- piker/data/_timeseries.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/piker/data/_timeseries.py b/piker/data/_timeseries.py index 7055854b..cc84f763 100644 --- a/piker/data/_timeseries.py +++ b/piker/data/_timeseries.py @@ -209,8 +209,13 @@ def detect_null_time_gap( NOTE: for now presumes only ONE gap XD ''' - zero_pred: np.ndarray = shm.array['time'] == 0 - zero_t: np.ndarray = shm.array[zero_pred] + # ensure we read buffer state only once so that ShmArray rt + # circular-buffer updates don't cause a indexing/size mismatch. + array: np.ndarray = shm.array + + zero_pred: np.ndarray = array['time'] == 0 + zero_t: np.ndarray = array[zero_pred] + if zero_t.size: istart, iend = zero_t['index'][[0, -1]] start, end = shm._array['time'][