From f2d41102dd7a219b33fa5385716f8041bba43753 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Wed, 1 Feb 2017 05:24:51 -0800 Subject: [PATCH] Ignore Exceptions While Parsing Frames (#1235) --- tests/scripts/thread-cert/sniffer.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/scripts/thread-cert/sniffer.py b/tests/scripts/thread-cert/sniffer.py index a9bc9c3bc..bf46c986a 100644 --- a/tests/scripts/thread-cert/sniffer.py +++ b/tests/scripts/thread-cert/sniffer.py @@ -80,11 +80,18 @@ class Sniffer: while self._thread_alive.is_set(): data, nodeid = self._transport.recv(self.RECV_BUFFER_SIZE) - msg = self._message_factory.create(io.BytesIO(data)) + # Ignore any exceptions + try: + msg = self._message_factory.create(io.BytesIO(data)) - if msg is not None: - self.logger.debug("Received message: {}".format(msg)) - self._buckets[nodeid].put(msg) + if msg is not None: + self.logger.debug("Received message: {}".format(msg)) + self._buckets[nodeid].put(msg) + + except Exception as e: + # Just print the exception to the console + print("EXCEPTION: %s" % e) + pass self.logger.debug("Sniffer stopped.")