I have a thread which should execute max 3 minutes. if it is exceeds 3 minutes I need to kill it. My current code snippet given below.Please note I can't use multiprocessing module in python.
def test_th():
p = threading.Thread(target=update_fm,name="update_fm", args=(url,))
p.start()
p.join(180)
log.debug("isalive :",p.isAlive())
def update_fm(fv_path):
output = None
try:
output = subprocess.check_output('wget {0} -O /tmp/test_fm'.format(fv_path), stderr=subprocess.STDOUT, shell=True)
except:
log.error("Error while downloading package, please try again")
return FAIL
if output:
log.info('going to upgrade cool :)')
return SUCCESS
return FAIL