client: change online state before callback
the client in NICOS is referring to the online state within the callback. + better error handling
This commit is contained in:
parent
4d7e5d3cdc
commit
10dad6da47
@ -493,17 +493,12 @@ class SecopClient(ProxyClient):
|
|||||||
self.log.warning('unhandled message: %s %s %r' % (action, ident, data))
|
self.log.warning('unhandled message: %s %s %r' % (action, ident, data))
|
||||||
|
|
||||||
def _set_state(self, online, state=None):
|
def _set_state(self, online, state=None):
|
||||||
# treat reconnecting as online!
|
# remark: reconnecting is treated as online
|
||||||
state = state or self.state
|
|
||||||
try:
|
|
||||||
self.callback(None, 'nodeStateChange', online, state)
|
|
||||||
for mname in self.modules:
|
|
||||||
self.callback(mname, 'nodeStateChange', online, state)
|
|
||||||
except Exception as e:
|
|
||||||
self.log.error('ERROR in nodeStateCallback %s', e)
|
|
||||||
# set online attribute after callbacks -> callback may check for old state
|
|
||||||
self.online = online
|
self.online = online
|
||||||
self.state = state
|
self.state = state or self.state
|
||||||
|
self.callback(None, 'nodeStateChange', self.online, self.state)
|
||||||
|
for mname in self.modules:
|
||||||
|
self.callback(mname, 'nodeStateChange', self.online, self.state)
|
||||||
|
|
||||||
def queue_request(self, action, ident=None, data=None):
|
def queue_request(self, action, ident=None, data=None):
|
||||||
"""make a request"""
|
"""make a request"""
|
||||||
@ -522,8 +517,8 @@ class SecopClient(ProxyClient):
|
|||||||
raise ConnectionError('connection closed before reply')
|
raise ConnectionError('connection closed before reply')
|
||||||
action, _, data = entry[2] # pylint: disable=unpacking-non-sequence
|
action, _, data = entry[2] # pylint: disable=unpacking-non-sequence
|
||||||
if action.startswith(ERRORPREFIX):
|
if action.startswith(ERRORPREFIX):
|
||||||
errcls = self.error_map(data[0])
|
errcls = self.error_map(data[0] + "Error")
|
||||||
raise errcls('on SEC-Node: ' + data[1])
|
raise errcls(data[1])
|
||||||
return entry[2] # reply
|
return entry[2] # reply
|
||||||
|
|
||||||
def request(self, action, ident=None, data=None):
|
def request(self, action, ident=None, data=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user