Hi all, I don't understand the signal module. I guess I understand what it does in principle but I can't figure out how to use it to timeout an external rsh command after a 5 seconds. Does anyone know how to do this. Here is what I have so far - which is largely based on the example on the man page..
def handler(signum, frame): print 'Signal handler called with signal', signum raise IOError, "Couldn't open device!" for host in alive: try: # Set the signal handler and a 5-second alarm signal.signal(signal.SIGALRM, handler) signal.alarm(5) (out,results) = commands.getstatusoutput( "rsh %s uname -a" % host) signal.alarm(0) # Disable the alarm #self.logger.debug( "%s Connection to %s - %s" % (out,host,results)) if out ==256: noaccess.append(host) del alive[host] break if out == 0: if re.search("SunOS",results): hosttype="sun" elif re.search("Linux",results): hosttype="linux" Can anyone point me in the right direction. Much appreciated!! -- http://mail.python.org/mailman/listinfo/python-list