此实用工具被设计为运行任何shell命令,如果在指定的超时时间内没有写入新的STODUT行,则重试。
console-retr的Python项目详细描述
控制台重试
此实用程序旨在运行任何shell命令,如果没有新行被写入,则重试 在指定的超时内执行stdout。在ci中特别有用,可以重试片状测试/脚本
默认超时适用于写入shell命令stdout的行。
在以下情况下触发重试:
- 指定超时后没有新行写入stdout
以下情况下不会触发重试:
- 整个命令所需的时间比指定的超时时间长
- 该命令返回非零(错误)返回代码
要成为一个好的bash公民,返回代码是子命令的返回代码的镜像,如果命令从来没有 在指定的超时内完成。
示例使用/测试
console-retry -t 10 "echo abcd ; false" # Immediate fail
console-retry -r 1 "sleep 70" # Fail after default timeout = 60
console-retry -s -r 1 -t 10 "sleep 15" # Should "skip timeout and therefore succeed after 15s"
console-retry -t 10 "echo abcd ; true" # Immediate success
console-retry -p -o abcd -t 10 " sleep 5; echo abc ;sleep 20; false" # Should Complete with error on second try
console-retry -o abcd -t 10 " sleep 5; echo abc ;sleep 20; false" # Should fail after retrymax (no progressive)
console-retry -o abc -t 10 " sleep 5; echo abc ; false" # Should retry max but never with ok
console-retry -o abc -t 10 ">&2 echo abc ; false" # stderr, should retry max
console-retry -o nomatch -t 10 ">&2 echo abc ; false" # stderr, should fail immediately
console-retry -o abc -t 10 "echo abc ; true" # stderr, should succeed immediately
console-retry -o nomatch -t 10 ">&2 echo abc ; sleep 2; echo def; true" # Output should be: abc \ndef
console-retry -t 10 ">&2 echo abc ; sleep 10; echo def; sleep 10; true" # Staggered output