From 737643c33c70c9c411cb38175ac97d7b4755fee5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 27 Aug 2014 09:54:58 -0400 Subject: [PATCH] Fix IO worker tolerance of errors If an _io_apply encounters an exception, the io worker entirely would fall apart. Encompass the key entry points in try clauses to allow the thread to keep working and the dependent IPMI object to have their waiter acknowledged. It's still considered a grave bug for this to ever occur, but at least the application would carry on. Change-Id: I61b0797025b25c6d9d3e86a5110603a6fc2d67fb --- pyghmi/ipmi/private/session.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index fc45fc48..a20bbfc3 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -27,6 +27,7 @@ import select import socket import struct import threading +import traceback from Crypto.Cipher import AES @@ -109,10 +110,16 @@ def _ioworker(): workitem = ioqueue.popleft() # structure is function, args, list to append to ,event to set if isinstance(workitem[1], tuple): # positional arguments - workitem[2].append(workitem[0](*workitem[1])) + try: + workitem[2].append(workitem[0](*workitem[1])) + except Exception: + traceback.print_exc() workitem[3].set() elif isinstance(workitem[1], dict): - workitem[2].append(workitem[0](**workitem[1])) + try: + workitem[2].append(workitem[0](**workitem[1])) + except Exception: + traceback.print_exc() workitem[3].set() elif workitem[0] == 'wait': if len(rdylist) > 0: @@ -139,7 +146,10 @@ def _io_apply(function, args): def _io_sendto(mysocket, packet, sockaddr): #Want sendto to act reasonably sane.. mysocket.setblocking(1) - mysocket.sendto(packet, sockaddr) + try: + mysocket.sendto(packet, sockaddr) + except Exception: + pass def _io_recvfrom(mysocket, size):