就像标题所说的那样,我正在尝试运行一些execfile
调用,但我正在寻找一个超时选项,这样如果我的被调用脚本需要超过 10 秒才能运行,那么它将终止被调用脚本并继续......
信号库/包仅适用于 UNIX,我在 Windows 上,所以我有点卡住了。
# Sequential wait to finish before moving onto the next script
try:
execfile("SUBSCRIPTS/TESTSCRIPT.py", {})
except Exception:
errors.write(traceback.format_exc() + '\n')
errors.write("\n\n")
# Semi-Sequential (Don't wait for it to finish before moving onto the third script)
subprocess.Popen(["pythonw", "SUBSCRIPTS/TEST.py", "0"], shell=True)
# Sequential wait to finish before moving onto the next script
try:
execfile("SUBSCRIPTS/TEST.py", {})
except Exception:
errors.write(traceback.format_exc() + '\n')
errors.write("\n\n")
# Sequential wait to finish before moving onto the next script
try:
execfile("SUBSCRIPTS/TESTSCRIPT.py", {})
except Exception:
errors.write(traceback.format_exc() + '\n')
errors.write("\n\n")
有任何想法吗?