当前位置:网站首页>Aardio - 函数执行失败重试测试
Aardio - 函数执行失败重试测试
2022-07-21 02:26:00 【卢光庆】
import console;
// 定义通用重试函数
var retry = function(num,func,...){ // 重试次数、执行的函数名、参数
var args = {...};
import win;
for(i=1;num;1){
console.dump("第"++i++"次重试!")
var 结果,是否重试=null,true;
try{
结果 = func(..table.unpack(args));
}
catch(e){
if ..string.endWith(e,"{Error}:123") 是否重试=false;
}
if 结果 return 结果;
if i==num or !是否重试 return;
win.delay()
}
}
// 访问正常的情况
var t = retry(3,function(){
import inet.http
return inet.http().get("http://www.baidu.com")
}
)
console.dump(#t)
//访问失败的情况
var t = retry(3,function(){
import inet.http
return inet.http().get("http://光庆.baidu.com")
}
)
console.dump(t)
//访问异常,继续重试的情况
var t = retry(3,function(){
error("函数执行错误!") //抛出异常
}
)
console.dump(t)
//访问异常,自定义过滤这种情况,不再重试
var t = retry(3,function(){
error(123) // 抛出不再重试的异常(自定义)
}
)
console.dump(t)
console.pause(true);
边栏推荐
- NFS共享
- 众昂矿业:萤石行业发展四大趋势
- Zhongang Mining: four trends of fluorite industry development
- C语言经典实例:21-30例:插入排序、希尔排序1、快速排序、希尔排序2、递归法、完数、斐波那契数列、公约数和公倍数、判断水仙花数统计单词个数
- ESB combined with UMC cloud platform development instructions
- If the recommendation effect is not satisfactory, it's better to try to learn the propeller chart
- Okaleido tiger NFT即将登录Binance NFT平台,NFT权益时代即将开启
- Zero basic learning canoe panel (1) -- new panel
- Player update and corresponding new function addition in easynvs customization project
- canal. Deployer-1.1.6 encountered dump address has an error, retrying Caused by problem
猜你喜欢
【04】穿越功耗墙,我们该从哪些方面提升“性能”?
c语言入门---操作符
Zhongang Mining: four trends of fluorite industry development
NFT与奢侈品文化的天然契合:NFT满足了人类寻求独特性和地位的天性
求解单源最短路径的手工实现
HCIP第四天
Detailed understanding of mvcc of MySQL (version 2022)
数字孪生技术打造智慧矿山可视化解决方案
Php-cgi Remote Code Execution Vulnerability (cve-2012-1823)
Tiflash source code reading (V) deltatree storage engine design and implementation analysis - Part 2
随机推荐
The risk control data (model) is not bothered because of the processing skills in this flow process
Qt development skills and three problems
C language practice topic + answer: 26-30
NepCTF2022
ACM集训7月5号
Design of the multi live architecture in different places of the king glory mall
Natural fit between NFT and luxury culture: NFT meets the human nature of seeking uniqueness and status
触发器基础知识(上)
手工遍历二叉树的技巧
qt开发技巧与三个问题点
C language practice topic + answer: 21-25
C语言练习题目+答案:26-30
In the post deep learning era, where is the recommendation system going?
Tiflash source code reading (V) deltatree storage engine design and implementation analysis - Part 2
Day009循环结构(练习)
el-table支持分页多选
Okaleido tiger NFT即将登录Binance NFT平台,NFT权益时代即将开启
数字孪生落地高铁桥梁可视化解决方案
Resttemplate calls post\get
Is it fast to render C4d with cloud?