A
amaccormack
I wrote a quick script to check the "up-ness" of a list of machines,
and timeout after 1 second. However, with a lot of timeouts, the
script takes a logn time, so I thought to parallelise it. However, as
soon as I do, the pings that do not get a response never return, so
their threads block forever and the program hangs. Environment is:
Python 2.3.3 (#1, Jan 5 2005, 15:24:27) [GCC 3.3.3 (SuSE Linux)] on
linux2 (running on SLES9)
pinglist=[]
class testit(Thread):
def __init__ (self,ip):
Thread.__init__(self)
self.ip = ip
self.status = -1
def run(self):
# -w 1 option to ping makes it timeout after 1 second
pingcmd="/bin/ping -c 2 -q -i 0.3 -w 1 %s >/dev/null" % ip
self.status = os.system(pingcmd)
def serping(ip):
pingcmd="/bin/ping -c 2 -q -i 0.3 -w 1 %s >/dev/null" % ip
os.system(pingcmd)
for machname in machlist:
#serping(machname) # this works in serial, and works
current = testit(machname) # this works in parallel, and
doesn't work
pinglist.append(current)
current.start()
# Wait for all pings to pong
for pingle in pinglist:
pingle.join()
Anyone got an idea what's going on? Is it the way that the ping
timeout works in SuSE is not thread-safe?
and timeout after 1 second. However, with a lot of timeouts, the
script takes a logn time, so I thought to parallelise it. However, as
soon as I do, the pings that do not get a response never return, so
their threads block forever and the program hangs. Environment is:
Python 2.3.3 (#1, Jan 5 2005, 15:24:27) [GCC 3.3.3 (SuSE Linux)] on
linux2 (running on SLES9)
pinglist=[]
class testit(Thread):
def __init__ (self,ip):
Thread.__init__(self)
self.ip = ip
self.status = -1
def run(self):
# -w 1 option to ping makes it timeout after 1 second
pingcmd="/bin/ping -c 2 -q -i 0.3 -w 1 %s >/dev/null" % ip
self.status = os.system(pingcmd)
def serping(ip):
pingcmd="/bin/ping -c 2 -q -i 0.3 -w 1 %s >/dev/null" % ip
os.system(pingcmd)
for machname in machlist:
#serping(machname) # this works in serial, and works
current = testit(machname) # this works in parallel, and
doesn't work
pinglist.append(current)
current.start()
# Wait for all pings to pong
for pingle in pinglist:
pingle.join()
Anyone got an idea what's going on? Is it the way that the ping
timeout works in SuSE is not thread-safe?