r - Prompt user without waiting -
i have long running process, coded in "r". continue running in rstudio, don't want use batch mode.
i allow user gracefully terminate long running process, example pressing escape key. if user doesn't press anything, process continues, without waiting.
i have read other stackoverflow posts, perhaps need prompt user using scan/readline on different thread. way, main execution thread isn't blocked.
isn't there simpler way?
thank pointers/suggestions.
richard rogers
further comments:
i've made few mistakes:
- i didn't realize pressing escape in rstudio while code running halts execution.
- i can't seem determine execution ends when press escape.
- maybe can use simpler question.
here simple function:
processdata <- function() { continue <- true iteration <- 1 testdata <- vector(mode = "integer", length = 100000) while (continue) { writelines(sprintf("processing iteration %d, current time %s", iteration, sys.time())) process.events() testdata <- round(runif(100000, min = 1, max = 10)) # continue <- promptuser() iteration <- iteration + 1 } writelines("processing ending.") head(testdata) }
if press escape while loop running, writelines , head calls don't executed. how can ensure do?
thank again,
richard
Comments
Post a Comment