From 2c66613b889e970de29df238c1e8021684ac8f30 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Thu, 1 Jun 2023 17:38:16 +0200 Subject: [PATCH] added a timeout counter, also as fake channel --- bstrd/bscache.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bstrd/bscache.py b/bstrd/bscache.py index 3cab89d..b220657 100644 --- a/bstrd/bscache.py +++ b/bstrd/bscache.py @@ -26,14 +26,18 @@ class BSCache: def run(self, running): + timeout_counter = 0 configs = self.channels.values() with source(channels=configs, receive_timeout=self.timeout) as src: while running.is_set(): msg = src.receive() if msg is None: + timeout_counter += 1 + print("receive timed out", timeout_counter) continue data = repack(msg) if data: + data["toc"] = timeout_counter yield data @@ -42,7 +46,7 @@ class BSCache: def get_var(self, name, modulo=None, offset=None): - if name != "pid" and name not in self.channels: + if name not in ["pid", "toc"] 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)