def run(self): start = time.time() while time.time() - start < 30: sd = linda.connect(self.serverport) if sd: sd = linda.getSD() break time.sleep(1) if time.time() - start >= 30: print "Unable to connect to server. The Monitor is exiting." return linda.send(sd, ("MONITOR", )) linda.recv(sd) while True: try: self.realrun(sd) break except: print "Caught exception" raise print "Monitor shutting down..." linda.disconnect()
#!/usr/bin/python import sys import _linda as linda if __name__ == "__main__": if not linda.connect(): sys.stderr.write("Error. Cannot connect to server.\n") sys.exit(-1) linda.uts._out((100, )) linda.disconnect()