Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put background job output on the RStudio job pane #255

Open
gaborcsardi opened this issue May 19, 2020 · 0 comments
Open

Put background job output on the RStudio job pane #255

gaborcsardi opened this issue May 19, 2020 · 0 comments
Labels
feature a feature request or enhancement

Comments

@gaborcsardi
Copy link
Member

gaborcsardi commented May 19, 2020

poc on Unix:

unlink("/tmp/fifo")
system("mkfifo /tmp/fifo")
script <- quote({
  conn <- processx::conn_create_file("/tmp/fifo")
  repeat {
    out <- processx::conn_read_chars(conn)
    if (nchar(out) == 0) break
    cat(out)
  }
})
cat(deparse(script), file = "/tmp/script.R", sep = "\n")
id <- rstudioapi::jobRunScript("/tmp/script.R")
id

pp <- processx::process$new(
  "bash",
  c("-c", "for i in `seq 1 100`; do sleep 1; echo $i; done"),
  stdout = "/tmp/fifo"
)

# Now you can even do these and more
pp$suspend()
pp$resume()

# rstudioapi::launcherControlJob(id, "kill")
rstudioapi::jobRemove(id)

API can be stdout = "|rstudio" or we can even have a new function that does this, and inherit from process and add methods to manage the rstudio job. But then it will no work for the other subclasses, like r_process.

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant