From bb8e0c74582dae669bd34bf4ab9915a29d407b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 4 May 2019 21:13:58 +0200 Subject: [PATCH] Handle JSON serialization errors in PipeIOEventHandler --- lib/tfw/components/pipe_io_event_handler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tfw/components/pipe_io_event_handler.py b/lib/tfw/components/pipe_io_event_handler.py index d610f4f..7604787 100644 --- a/lib/tfw/components/pipe_io_event_handler.py +++ b/lib/tfw/components/pipe_io_event_handler.py @@ -23,8 +23,12 @@ class PipeIOEventHandler(EventHandlerBase): self._pipe_io_server.stop() def handle_event(self, message): - json_bytes = dumps(message).encode() - self._pipe_io_server.send_message(json_bytes) + try: + json_bytes = dumps(message).encode() + self._pipe_io_server.send_message(json_bytes) + except TypeError: + LOG.error("Message %s not JSON serializable! Ignoring...", message) + class JSONProxyPipeIOServer(PipeIOServer):