Hello everyone,
I am having a tiny problem putting together a small script. I tried throwing together a multi-threaded ping utility, but the threads are not behaving the way I anticipated...P erhaps one of you could look and see why this is happening.
Python 2.5.2, Ubuntu 8.04
[code=python]
#! /usr/bin/env python
import os, sys, threading
class PingThread(thre ading.Thread):
host = ''
def __init__(self, host):
self.host = host
threading.Threa d.__init__(self )
def run (self):
os.execv('/bin/ping', ['/bin/ping', self.host])
print "PingThread('go ogle.com').star t()"
PingThread('goo gle.com').start ()
print "PingThread('ya hoo.com').start ()"
PingThread('yah oo.com').start( )
print "Main thread ended."
[/code]
If someone could point out my misuse of the Thread class, I would appreciate it.
Thanks,
Motoma
I am having a tiny problem putting together a small script. I tried throwing together a multi-threaded ping utility, but the threads are not behaving the way I anticipated...P erhaps one of you could look and see why this is happening.
Python 2.5.2, Ubuntu 8.04
[code=python]
#! /usr/bin/env python
import os, sys, threading
class PingThread(thre ading.Thread):
host = ''
def __init__(self, host):
self.host = host
threading.Threa d.__init__(self )
def run (self):
os.execv('/bin/ping', ['/bin/ping', self.host])
print "PingThread('go ogle.com').star t()"
PingThread('goo gle.com').start ()
print "PingThread('ya hoo.com').start ()"
PingThread('yah oo.com').start( )
print "Main thread ended."
[/code]
If someone could point out my misuse of the Thread class, I would appreciate it.
Thanks,
Motoma
Comment