Using Signal Handler to timeout an rsh call
sklass at pointcircle.com
Mon Aug 22 16:07:51 CEST 2005
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
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:
# Set the signal handler and a 5-second alarm
(out,results) = commands.getstatusoutput( "rsh %s uname
-a" % host)
signal.alarm(0) # Disable the alarm
#self.logger.debug( "%s Connection to %s - %s" %
if out ==256:
if out == 0:
Can anyone point me in the right direction. Much appreciated!!
More information about the Python-list