def is_timeout(app, pr): # check if the process is active every 'factor' sec for timeout threshold
factor = 0.25
retcode = None
tt = cp.TIMEOUT_THRESHOLD * sp.apps[app][2] # sp.apps[app][2] = expected runtime
if tt < 10: tt = 10
to_th = tt / factor
while to_th > 0:
retcode = pr.poll()
if retcode is not None:
break
to_th -= 1
time.sleep(factor)
if to_th == 0:
os.killpg(pr.pid, signal.SIGKILL) # pr.kill()
print "timeout"
return [True, pr.poll()]
else:
return [False, retcode]
###############################################################################
# Run the actual injection run
###############################################################################
评论列表
文章目录