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):