I have 2 scripts.
main.py
import threading
import time
import os
exitflag = 0
class Testrun(threading.Thread):
def __init__(self,threadID,name,delay):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.delay = delay
def run(self):
print 'launching test '+self.name
launch_test(self.name,self.delay)
print 'exitiing test '+self.name
def launch_test(threadname,delay):
os.system('test.py')
if exitflag ==1:
threadname.exit()
thread = Testrun(1,'test',10)
thread.start()
Which calls test.py:
import time
while True:
print 'hello'
time.sleep(1)
After a delay of 30 secs I want to terminate test.py.
I am using python 2.4.2.
Is there any way to do this with event generation
Any suggestion to this code or any other alternative module will do.