Fix handling of 0 history samples range

This can happen when polling the history buffer very frequently (<= 1 second).
This commit is contained in:
sparky8512 2021-02-14 13:47:24 -08:00
parent 2ac5944824
commit 30e4b27516

View file

@ -765,6 +765,9 @@ def _compute_sample_range(history, parse_samples, start=None, verbose=False):
if start is None or start < current - parse_samples: if start is None or start < current - parse_samples:
start = current - parse_samples start = current - parse_samples
if start == current:
return range(0), 0, current
# This is ring buffer offset, so both index to oldest data sample and # This is ring buffer offset, so both index to oldest data sample and
# index to next data sample after the newest one. # index to next data sample after the newest one.
end_offset = current % samples end_offset = current % samples