From 47a3a24a7df632ea216b438739df1006ee7a1d67 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 19 May 2015 02:39:26 +0530 Subject: [PATCH] ignore messages that can not be serialized --- pandora/websocket/daemon.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pandora/websocket/daemon.py b/pandora/websocket/daemon.py index bd3227788..46160dbd6 100644 --- a/pandora/websocket/daemon.py +++ b/pandora/websocket/daemon.py @@ -62,14 +62,22 @@ class Handler(WebSocketHandler): #logger.debug('got message %s', message) def post(self, event, data): - message = json.dumps([event, data]) + try: + message = json.dumps([event, data]) + except: + logger.debug('failed to serialize data %s %s', event, data) + return main = IOLoop.instance() main.add_callback(lambda: self.write_message(message)) def trigger_event(event, data): logger.debug('trigger event %s %s to %s clients', event, data, len(sockets)) main = IOLoop.instance() - message = json.dumps([event, data]) + try: + message = json.dumps([event, data]) + except: + logger.debug('faild to serialise data') + return for ws in sockets: try: main.add_callback(lambda: ws.write_message(message))