_C() Re-test the function

Author: The Arctic, Created: 2017-02-24 16:46:40, Updated:

_C ((function, args...) retry function, which will keep calling the specified function until successfully returning (the function returning null or false will retry), such as _C ((exchange.GetTicker), with a default retry interval of 3 seconds, can redefine the variable _CInterval to control the retry interval When the function returns a failed result, try again every 3 seconds.

If there are no parameters _C (name of function)

Functions with parameters _C (name of function, parameters of function)

JavaScript

function main() {
    Log(exchange.GetAccount());    //一般调用形式
    
    _CInterval=1;                  //重新 设置重试间隔时间(秒)
    
    Log(_C(exchange.GetAccount));  //使用_C调用形式  不带参数
    
    Log(_C(exchange.GetRecords,PERIOD_M1)); //使用_C调用形式  带参数形式
}

Code retested the results of the run:img

Python

def main():
    Log(exchange.GetAccount())    #一般调用形式
    
    _CInterval=1                  #重新 设置重试间隔时间(秒)

    Log(_C(exchange.GetAccount)) #使用_C调用形式  不带参数
    
    Log(_C(exchange.GetRecords,PERIOD_M1)) #使用_C调用形式  带参数形式

Code retested the results of the run:img


More

flydogI can't see the exchange account information? Don't know why?

flydog function main() { Log(_C(exchange.GetAccount())); Log("test"); }

flydog https://dn-filebox.qbox.me/677304fbc2a5c448040610b824420e2e0375952e.png

penglihengSo the system shows that the return is still zero.

I'm not sure.Can the retry function set the number of retries, otherwise it's an infinite loop, and you have to control the exit loop in other ways, which is a bit of a hassle.

McQueenThis is to prevent an API error that causes no return value.