Below you find a piece of code that demonstrates how users are notified after a time-out is detected in the reset() function of a VcExecutor.
Notice that signal.alarm() cannot be used because the VcExecutor is not executed in the main thread.
Notice also that the function HasyUtils.notifyUser() notifies all users, if no second argument is supplied.
The message is sent to users working on the host that runs the MacroServer. If this is a remote host, the message is sent via ssh.
The VcExecutor host and the MacroServer host have to be in one Tango DB.
#!/bin/env python ... import HasyUtils import PyTango import time import threading ... class VC: def __init__(self): .... self.timeout = False ... def alarm_handler( self): self.flagTimeout = True raise TimeoutError("Alarm triggered!") # # reset # def Reset(self): timeout_interval = 2 timer = threading.Timer(timeout_interval, self.alarm_handler) self.flagTimeout = False timer.start() try: # # generate a time-out # time.sleep(3) except TimeoutError as e: # also in the case of a tmo we do not arrive here, # so we have to set the timeout flag in alarm_handler pass finally: timer.cancel() if self.flagTimeout: HasyUtils.notifyUser( "signalGenerator.reset: timeout - consider to RestartBoth") return True