protect against parser errors to prevent queue backlogging

This commit is contained in:
Jakob Ketterl 2021-01-22 19:48:31 +01:00
parent 68a1abd37e
commit a0d219d120
2 changed files with 14 additions and 7 deletions

View File

@ -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")

View File

@ -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()