Catch exception so websocket doesn't crash when failed to process data

This commit is contained in:
JonnyWong16 2017-08-23 20:33:14 -07:00
parent bbe309e7bd
commit cd007ee0eb

View file

@ -191,8 +191,11 @@ def process(opcode, data):
logger.debug(u"PlexPy WebSocket :: Session found but unable to get timeline data.") logger.debug(u"PlexPy WebSocket :: Session found but unable to get timeline data.")
return False return False
try:
activity = activity_handler.ActivityHandler(timeline=time_line[0]) activity = activity_handler.ActivityHandler(timeline=time_line[0])
activity.process() activity.process()
except Exception as e:
logger.error(u"PlexPy WebSocket :: Failed to process session data: %s." % e)
if type == 'timeline': if type == 'timeline':
time_line = info.get('TimelineEntry', info.get('_children', {})) 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.") logger.debug(u"PlexPy WebSocket :: Timeline event found but unable to get timeline data.")
return False return False
activity = activity_handler.TimelineHandler(timeline=time_line[0]) try:
activity = activity_handler.ActivityHandler(timeline=time_line[0])
activity.process() activity.process()
except Exception as e:
logger.error(u"PlexPy WebSocket :: Failed to process timeline data: %s." % e)
return True return True