Last active
December 29, 2020 05:24
-
-
Save GeorgeOduor/35a694c86acc75a92aa114c43059ae14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# want to keep retryng until a condition is met then run your script?here you go...... | |
library(futile.logger) | |
library(utils) | |
eod_check <- function(){ | |
eod_file = readxl::read_excel('D:/test.xlsx') | |
return(eod_file$Status) | |
} | |
retry_until <- function(expr, maxErrors=5, sleep=0) { | |
retval = try(eval(expr)) | |
while (T) { | |
until = eod_check() | |
if (until) { | |
msg = "Condtion is met do something" | |
message(msg) | |
break() | |
} else { | |
msg = "Condition isnt done yet but i will retry" | |
flog.error(msg) | |
# warning(msg) | |
} | |
if (sleep > 0) Sys.sleep(sleep) | |
retval = try(eval(expr)) | |
} | |
return(retval) | |
} | |
retry_until(3+3,sleep = 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment