From a0d219d120e38837049aaa2d0e017b17455475fc Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 22 Jan 2021 19:48:31 +0100 Subject: [PATCH] protect against parser errors to prevent queue backlogging --- owrx/pocsag.py | 17 ++++++++++++----- owrx/wsjt.py | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/owrx/pocsag.py b/owrx/pocsag.py index 0d7f750..c265146 100644 --- a/owrx/pocsag.py +++ b/owrx/pocsag.py @@ -1,10 +1,17 @@ from owrx.parser import Parser +import logging + +logger = logging.getLogger(__name__) + class PocsagParser(Parser): def parse(self, raw): - fields = raw.decode("ascii", "replace").rstrip("\n").split(";") - meta = {v[0]: "".join(v[1:]) for v in map(lambda x: x.split(":"), fields) if v[0] != ""} - if "address" in meta: - meta["address"] = int(meta["address"]) - self.handler.write_pocsag_data(meta) + try: + fields = raw.decode("ascii", "replace").rstrip("\n").split(";") + meta = {v[0]: "".join(v[1:]) for v in map(lambda x: x.split(":"), fields) if v[0] != ""} + if "address" in meta: + meta["address"] = int(meta["address"]) + self.handler.write_pocsag_data(meta) + except Exception: + logger.exception("Exception while parsing Pocsag message") diff --git a/owrx/wsjt.py b/owrx/wsjt.py index fb8df5b..6d9a919 100644 --- a/owrx/wsjt.py +++ b/owrx/wsjt.py @@ -176,8 +176,8 @@ class WsjtParser(Parser): ReportingEngine.getSharedInstance().spot(out) self.handler.write_wsjt_message(out) - except (ValueError, IndexError): - logger.exception("error while parsing wsjt message") + except Exception: + logger.exception("Exception while parsing wsjt message") def pushDecode(self, mode): metrics = Metrics.getSharedInstance()