2009/2/17 Mamahita Sela <[email protected]>:
> Hi Graham,
>
> Thank you very much. Your code, sure it helps.
>
> But, i still found that it only print (many many times) the ping result of
> first host (which is no reply host). Is this because i did not join all the
> threads?
>
> This is what i worry about threading. Should i join the threads manually?
>
> Please advise,
> M
>
Sorry, that's because of a typo in the code I posted. I indented the
return statement in the Main.do_ping() function too far. It should
have been:
def do_ping(self):
for h in range(100, 120):
host = '192.168.0.%d' %(h)
#
worker = PingHost(host, self.ping_result)
worker.start()
return True
Also, noting John's comment above, the PingHost.run() function would
be improved by writing it:
def run(self):
result = self.host, commands.getstatusoutput('ping %s -c1' %(self.host))[0]
gobject.idle_add(self.callback, result)
And the callback function should return False. This way the callback
will be executed in the gtk.main() loop which is probably what you
want.
Graham
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/