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 from owrx.parser import Parser
import logging
logger = logging.getLogger(__name__)
class PocsagParser(Parser): class PocsagParser(Parser):
def parse(self, raw): def parse(self, raw):
fields = raw.decode("ascii", "replace").rstrip("\n").split(";") try:
meta = {v[0]: "".join(v[1:]) for v in map(lambda x: x.split(":"), fields) if v[0] != ""} fields = raw.decode("ascii", "replace").rstrip("\n").split(";")
if "address" in meta: meta = {v[0]: "".join(v[1:]) for v in map(lambda x: x.split(":"), fields) if v[0] != ""}
meta["address"] = int(meta["address"]) if "address" in meta:
self.handler.write_pocsag_data(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) ReportingEngine.getSharedInstance().spot(out)
self.handler.write_wsjt_message(out) self.handler.write_wsjt_message(out)
except (ValueError, IndexError): except Exception:
logger.exception("error while parsing wsjt message") logger.exception("Exception while parsing wsjt message")
def pushDecode(self, mode): def pushDecode(self, mode):
metrics = Metrics.getSharedInstance() metrics = Metrics.getSharedInstance()