Example code using assertServerRunning()

The following code gives more information about how assertServerRunning is put into operation.

(1)
the function individualScan() is where most of the time is spent. Among other things it makes some motor movements which may fail because of Tango server crashes.

(2)
infoBlock is a class to store the server and the DB host name of a device. The information is collected at the very beginning from living servers. It is used when exceptions are caught.

(3)
the landing point for exceptions thrown from within individualScans(). The function assertServerRunning() is called for each server involved.

# (1)
def individualScan( motor1, motor2): 
  ...

class infoBlock(): pass

if __name__ == '__main__':

    #
    # (2) prepare the list of info blocks
    #
    infoBlocks = []
    for dev in [ "haspp99:10000/p99/motor/exp.01",
                 "haspp99:10000/p99/motor/exp.02"]:
        try:
            p = PyTango.DeviceProxy( dev)
        except: 
            print "main: failed to get proxy to %s, exiting" % dev
            sys.exit(255)
        ib = infoBlock()
        ib.dbHost = p.get_db_host()
        ib.serverName = p.info().server_id
        infoBlocks.append( ib)
    #
    # loop over the scans
    #
    while True:
        try:
            if not individualScan( "haspp99:10000/p99/motor/exp.01",
                                   "haspp99:10000/p99/motor/exp.02"):
                break
        #
        # (3) the landing point
        #
        except PyTango.DevFailed:
            for ib in infoBlocks:
                if not HasyUtils.assertServerRunning( ib.serverName, ib.dbHost):
                    print "main: assertServerRunning failed"
                    sys.exit(255)



2019-11-13