From cd007ee0eb3de543baef75300e777f96bd976cfd Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Wed, 23 Aug 2017 20:33:14 -0700 Subject: [PATCH] Catch exception so websocket doesn't crash when failed to process data --- plexpy/web_socket.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plexpy/web_socket.py b/plexpy/web_socket.py index 6a67c5ca..ebf594e8 100644 --- a/plexpy/web_socket.py +++ b/plexpy/web_socket.py @@ -191,8 +191,11 @@ def process(opcode, data): logger.debug(u"PlexPy WebSocket :: Session found but unable to get timeline data.") return False - activity = activity_handler.ActivityHandler(timeline=time_line[0]) - activity.process() + try: + activity = activity_handler.ActivityHandler(timeline=time_line[0]) + activity.process() + except Exception as e: + logger.error(u"PlexPy WebSocket :: Failed to process session data: %s." % e) if type == 'timeline': time_line = info.get('TimelineEntry', info.get('_children', {})) @@ -201,7 +204,10 @@ def process(opcode, data): logger.debug(u"PlexPy WebSocket :: Timeline event found but unable to get timeline data.") return False - activity = activity_handler.TimelineHandler(timeline=time_line[0]) - activity.process() + try: + activity = activity_handler.ActivityHandler(timeline=time_line[0]) + activity.process() + except Exception as e: + logger.error(u"PlexPy WebSocket :: Failed to process timeline data: %s." % e) return True