rstudio / rstudioapi

Safely access RStudio's API (when available)
http://rstudio.github.io/rstudioapi
Other
167 stars 36 forks source link

add customizable responses's time for prompts #291

Open capitantyler opened 8 months ago

capitantyler commented 8 months ago

It would be possible add customizable response's time for possible Rstudio form's prompts? I am looking at the code and this time was set in 10 secs, which is too short to fill them.

I have been having problems running jobs from RStudio if it has Rstudio prompts inside.

kevinushey commented 8 months ago

Can you please give an example? AFAIK RStudio shouldn't be timing out in any of the prompts exposed to rstudioapi.

capitantyler commented 8 months ago

The mentioned code is in the remote.R line 65

  # check for response
    if (file.exists(responseFile))
      break

    # check for lack of response
    diff <- difftime(Sys.time(), now, units = "secs")
    if (diff > 10)
      stop("RStudio did not respond to rstudioapi IPC request")

    # wait a bit
    Sys.sleep(0.1)

  }
kevinushey commented 8 months ago

Ahh, thanks -- so this is specifically for the case where rstudioapi is being invoked remotely; that is, from within an R child process. We can take a look at that.

capitantyler commented 8 months ago

Well, I called it from a R Job, Besides, I filled the prompt manually.

jonovik commented 2 months ago

I created a pull request to solve this, but am a bit surprised it was not autolinked here:

https://github.com/rstudio/rstudioapi/pull/301

Sorry about the force pushes to my fork; I didn't realize they were being linked here before I finalized my pull request. Please focus on the latest one (f2cc66e), and I'll make no more force pushes.