mirror of
https://opendev.org/x/pyghmi
synced 2025-01-28 20:07:42 +00:00
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
This commit is contained in:
parent
9bf8258edf
commit
737643c33c
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user