Example code using assertServerRunning()

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

# (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)