From e1aef2dc828c614cfbfe5e61a446136ca6cc3a17 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Wed, 7 Jun 2023 20:01:41 +0200 Subject: [PATCH] unified starting by checking all (instead of new) channels vs. received channels --- bstrd/bscache.py | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/bstrd/bscache.py b/bstrd/bscache.py index c8dbfac..a667ae7 100644 --- a/bstrd/bscache.py +++ b/bstrd/bscache.py @@ -47,6 +47,19 @@ class BSCache: yield data + def start(self): + self.pt.start() + + while self.data is None: + print("dropping empty data") + next(self) + + while not self.channels.keys() <= self.data.keys(): + missing = self.channels.keys() - self.data.keys() - FIXED_CHANNELS + print("dropping data that is missing channel(s):", sorted(missing)) + next(self) + + def stop(self): self.pt.stop() @@ -68,19 +81,10 @@ class BSCache: def update_source_multiple(self, chans): - self.pt.stop() + self.stop() print("add channels", sorted(chans)) self.channels.update(chans) - self.pt.start() - - while self.data is None: - print("dropping empty data") - next(self) - - while not chans.keys() <= self.data.keys(): - missing = self.data.keys() - chans.keys() - FIXED_CHANNELS - print("dropping data that is missing new channel(s)", sorted(missing)) - next(self) + self.start() def get_var(self, name, modulo=None, offset=None): @@ -93,18 +97,10 @@ class BSCache: def update_source(self, name, cfg): - self.pt.stop() + self.stop() print("add channel", name) self.channels[name] = cfg - self.pt.start() - - while self.data is None: - print("dropping empty data") - next(self) - - while name not in self.data: - print("dropping data that is missing new channel:", name) - next(self) + self.start() def flush(self):