from subprocess import Popen, PIPE from threading import Thread import time class test(Thread): def __init__(self): Thread.__init__(self) def run(self): p = Popen("ping -c 50 www.google.com", stdout=PIPE, shell=True) p.wait() #while not p.poll(): # time.sleep(.1) print "P ran ", p.returncode t = test() print "Starting test" t.run() print "Started!"