私は2つのスクリプトを持っています。私はtest.pyを終了したい30秒の遅延の後長期実行スクリプトを終了しますか?
import time
while True:
print 'hello'
time.sleep(1)
:test.pyを呼び出し
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()
。
私はPython 2.4.2を使用しています。 イベントの生成でこれを行う方法はありますか このコードまたは他の代替モジュールに対する提案は役に立ちます。
'launch_test(self.name、self.delay)'は関数にあまりにも多くの引数を渡しています。 ** main.py **は** test.py **を呼び出さず、** conthello.py **は何ですか? – martineau