From 36cf0d9724708099430c279779e30ff5bdc0a2f6 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Tue, 6 Jun 2023 11:32:22 +0200 Subject: [PATCH] added FIXED_CHANNELS constant --- bstrd/bscache.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bstrd/bscache.py b/bstrd/bscache.py index 8620366..c8dbfac 100644 --- a/bstrd/bscache.py +++ b/bstrd/bscache.py @@ -4,6 +4,12 @@ from .bsvar import BSVar from .prodthread import ProdThread +FIXED_CHANNELS = { + "pid", + "toc" +} + + class BSCache: def __init__(self, timeout=1000, maxsize=100): @@ -51,7 +57,7 @@ class BSCache: new_chans = {} for name, kwargs in names.items(): - if name not in ["pid", "toc"] and name not in self.channels: + if name not in FIXED_CHANNELS and name not in self.channels: if not is_available(name): raise ValueError(f"channel {name} is not available") cfg = make_channel_config(name, *kwargs) @@ -72,13 +78,13 @@ class BSCache: next(self) while not chans.keys() <= self.data.keys(): - missing = self.data.keys() - chans.keys() - {"pid", "toc"} + missing = self.data.keys() - chans.keys() - FIXED_CHANNELS print("dropping data that is missing new channel(s)", sorted(missing)) next(self) def get_var(self, name, modulo=None, offset=None): - if name not in ["pid", "toc"] and name not in self.channels: + if name not in FIXED_CHANNELS and name not in self.channels: if not is_available(name): raise ValueError(f"channel {name} is not available") cfg = make_channel_config(name, modulo, offset)