Example code using assertServerRunning()

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

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.

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.

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",
            p = PyTango.DeviceProxy( dev)
            print "main: failed to get proxy to %s, exiting" % dev
        ib = infoBlock()
        ib.dbHost = p.get_db_host()
        ib.serverName = p.info().server_id
        infoBlocks.append( ib)
    # loop over the scans
    while True:
            if not individualScan( "haspp99:10000/p99/motor/exp.01",
        # (3) the landing point
        except PyTango.DevFailed:
            for ib in infoBlocks:
                if not HasyUtils.assertServerRunning( ib.serverName, ib.dbHost):
                    print "main: assertServerRunning failed"