Handle JSON serialization errors in PipeIOEventHandler

This commit is contained in:
Kristóf Tóth 2019-05-04 21:13:58 +02:00
parent f94d571d19
commit bb8e0c7458

View File

@ -23,8 +23,12 @@ class PipeIOEventHandler(EventHandlerBase):
self._pipe_io_server.stop() self._pipe_io_server.stop()
def handle_event(self, message): def handle_event(self, message):
json_bytes = dumps(message).encode() try:
self._pipe_io_server.send_message(json_bytes) 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): class JSONProxyPipeIOServer(PipeIOServer):