[R] Communicating with R through a named pipe: display refresh problem
Parker Jones
zoubidoo at hotmail.com
Tue Jan 22 16:33:01 CET 2008
> Rather, non-interactive R does not run an event loop. The usual way
> around this is to use a pty, as R run from a pty is considered to be
> interactive.
>
> (Whether a fifo and a named pipe are the same concept is moot: some OSes
> have one and not the other.)
>
> The plan is to use threads in due course to handle X11 events.
>
I agree threads is the way to go.
In the meantime, I also tried a looping server which doesn't block on reads to a pipe. This still doesn't refresh the display but if R has a command to refresh the display then that will probably solve the problem.
# based on http://tolstoy.newcastle.edu.au/R/help/01c/2886.html
stream <- fifo("R_pipe", "r", blocking=FALSE,)
repeat
{
a <- readLines(stream)
if(length(a) != 0)
{
e <- try(eval(parse(text = a)))
if (inherits(e, "try-error"))
{
# error handling code here
cat("Error", "\n")
}
}
}
More information about the R-help
mailing list