Skip to content

Commit

Permalink
handle parse fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Jul 17, 2024
1 parent 71105f7 commit f5b2509
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gamutrflib/gamutrflib/zmqbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5b2509

Please sign in to comment.