client: timestamps must never lie in the future

+ use log.exception for error in callback
  (nicer when called from nicos)

Change-Id: If6d3036d9876457e57b996e5b20343d28f99451b
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31160
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2023-05-22 07:32:16 +02:00
parent d8c0a1c507
commit a643093934

View File

@ -245,8 +245,10 @@ class ProxyClient:
except UnregisterCallback: except UnregisterCallback:
cblist.remove(cbfunc) cblist.remove(cbfunc)
except Exception as e: except Exception as e:
# the programmer should catch all errors in callbacks
# if not, the log will be flooded with errors
if self.log: if self.log:
self.log.error('error %r calling %s%r', e, cbfunc.__name__, args) self.log.exception('error %r calling %s%r', e, cbfunc.__name__, args)
return bool(cblist) return bool(cblist)
def updateValue(self, module, param, value, timestamp, readerror): def updateValue(self, module, param, value, timestamp, readerror):
@ -398,6 +400,7 @@ class SecopClient(ProxyClient):
value = data[0] value = data[0]
readerror = None readerror = None
module, param = module_param module, param = module_param
timestamp = min(time.time(), timestamp) # no timestamps in the future!
try: try:
self.updateValue(module, param, value, timestamp, readerror) self.updateValue(module, param, value, timestamp, readerror)
except KeyError: except KeyError: