[Rd] Out buffers flushing

Greg Minshall m|n@h@|| @end|ng |rom um|ch@edu
Fri Jan 21 16:51:52 CET 2022


> I'm using R CMD BATCH output stream as control stream (via IPC) in my
> project. I noticed that sometimes I'm not receiving out line intime
> (that leads to unwanted behaviour). I suspect it is due to some
> buffering mechanism. I tried to use flush.console() but it does not
> help.

so, i'm not quite sure i understand the setup here.  you are running
some script via `R CMD BATCH`.  that i got.  but i don't know what you
mean with "(via IPC)".

if when running `R CMD BATCH` on a terminal, your output is showing up
in a timely way, but when running it some other way, the output is
delayed, you might try running (on Unix, say) it through a pipe like
and seeing if you still get the output in a timely way.  if not, then
there might be some buffering inside the R code that disables buffering
when going to a terminal, but does buffer when the output is going
somewhere other than your terminal (this is not uncommon in, e.g.,
Unix's "standard I/O library").

but, if that pipeline gives output in a timely manner, then maybe your
"IPC" mechanism is causing the problem.

i don't know if that will be of any help.

cheers, Greg

More information about the R-devel mailing list