我正在尝试弄清楚如何让python在一段时间后停止接受输入。 到目前为止,我得到的结果是有效的,但在用户按回车键之前不会停止程序。如果重要的话,我将在Anaconda提示符下运行此文件。 #I've made everything short so it's simpler
def f():
try:
if a != "Accepted word":
timer.cancel
print("...")
quit()
except NameE
我有一个shell脚本,在其中我调用了一个python脚本,即new.py
#!/usr/bin/ksh
python new.py
现在这个new.py类似于-
if not os.path.exists('/tmp/filename'):
print "file does not exist"
sys.exit(0)
如果文件不退出,则python脚本返回,但shell脚本继续执行。如果文件确实退出nt,并且我的python脚本退出,我希望shell脚本也在这一点上停止。
请建议如何在shell脚本中捕获返回,以进一步停止其执行。
我想用一个lambda脚本做一些简单的过滤,它会根据spamVerdict,virusVerdict等丢弃电子邮件。检查上下文对象的python文档似乎表明,我没有“成功”方法来停止处理SES规则集。此外,简单地调用:context.succeed({ "disposition" : "STOP_RULE_SET" });会给出错误:
"errorType": "AttributeError",
"errorMessage": "'LambdaContext' object has no a
我在raspberry pi上试用,发现CTRL+C或从菜单中选择shell > interrupt execution通常不会停止正在运行的脚本。
当我关闭整个窗口时,我确实得到了一个警告:your program is still running, do you want to kill it?,但看起来脚本甚至在窗口关闭时也会运行,因为对于所有python窗口,光标都会变成沙漏。
如何在raspberry上强制停止python脚本?