Reputation: 169
How is it possible to get a compiled .exe program written in Python to kill itself after a period of time after it is launched?
If I have some code and I compile it into an .exe, then launch it and it stays in a 'running' or 'waiting' state, how can I get it to terminate after a few mins regardless of what the program is doing?
The reason why is that the exe that is launched envokes a URL using PAMIE and automates some clicks. What I have noticed is that if the browser is closed the process remains in memory and does not clean itself up. I wanted to find a way to auto-clean up the process after say 5 mins which is more then enough time. I've tried using psutils to detect the process but that does not work in my case. Any suggestions is greatly appreciated.
Upvotes: 0
Views: 1732
Reputation: 503
def one(Time):
time.sleep(Time)
sys.exit(0)
def two():
thread.start_new_thread(one, (600,)) #10min countdown..
#Your running function here....Will run sim. with function one. when time ends,
#sys.exit exits program..(Not tested:) )
two()
Upvotes: 1
Reputation: 613362
Upvotes: 0