I'm trying to use the timeout_decorator. https://github.com/pnpnpn/timeout-decorator
I have the timeout defined else where in the code. I keep getting the following error:
NameError: name 'self' is not defined
class rtuCommsLib():
def __init__(self, _mirrorQueue):
self.CMD_LIST_SET = [ {'cmd' : 'MDM_ON', 'rtuCmd' : 'mdm on',
'pass': re.compile(r'([0])|(>[0])'), 'error' : re.compile(r'>[1-9]|[1-9]'),
'cmdState' : self.CMD_STATES['NONE'], 'timeout' : '1', 'returnValue' : None },
@timeout_decorator.timeout( self.CMD_LIST_SET[self.cmdIndex]['timeout'], timeout_exception=StopIteration)
def sendCmdWait(self):
#Wait for command to process
try:
while(self.CMD_LIST_SET[self.cmdIndex]['cmdState'] == self.CMD_STATES['WAITING']):
time.sleep(0.1)
return "SUCCESS"
except StopIteration:
print "Timeout Error"
return "ERROR"