From f5b25090396eb4e2f1194b4ed340bd5abf5f90ea Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Wed, 17 Jul 2024 01:03:27 +0000 Subject: [PATCH] handle parse fail. --- gamutrflib/gamutrflib/zmqbucket.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gamutrflib/gamutrflib/zmqbucket.py b/gamutrflib/gamutrflib/zmqbucket.py index 02f037e7..be3dc0fa 100644 --- a/gamutrflib/gamutrflib/zmqbucket.py +++ b/gamutrflib/gamutrflib/zmqbucket.py @@ -144,16 +144,19 @@ def __str__(self): return f"ZmqScanner on {self.addr}:{self.port}" def read_buff_file(self, log): + lines = None if os.path.exists(self.buff_file): self.info("read %u bytes of FFT data" % os.stat(self.buff_file).st_size) with self.context.stream_reader(open(self.buff_file, "rb")) as bf: txt_buf = bf.read().decode("utf8") if log: log.write(txt_buf) - lines = [json.loads(line) for line in txt_buf.splitlines()] + try: + lines = [json.loads(line) for line in txt_buf.splitlines()] + except json.decoder.JSONDecodeError as err: + logging.info("%s: %s", err, txt_buf) os.remove(self.buff_file) - return lines - return None + return lines def read_new_frame_df(self, df, discard_time): frame_df = None