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:

  1. i didn't realize pressing escape in rstudio while code running halts execution.
  2. i can't seem determine execution ends when press escape.
  3. 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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -