gpt4 book ai didi

python - 停止 Fabric 任务运行

转载 作者:行者123 更新时间:2023-12-01 05:41:48 24 4
gpt4 key购买 nike

如果我的一台服务器上的一项结构任务失败,我当前使用的方法是

try:
sudo(...)
except SystemExit():
raise Exception("You should fix this with...")

但是,当我只想打印异常中的消息时,这会在异常中留下令人不快的堆栈跟踪。但是,如果我不抛出此异常,那么当我希望 Fabric 脚本停止时,它会继续在我的其他服务器上运行。

有没有办法停止所有结构任务?

最佳答案

如果我理解正确,您希望停止在所有服务器上执行脚本并显示日志消息,但不显示堆栈跟踪。你可以这样做:

import sys
try:
sudo(...)
except SystemExit():
print "You should fix this with..." # you can use logging here
sys.exit()

关于python - 停止 Fabric 任务运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17349167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com