Hi all --- I'm new to using rApache, and have previously rolled my own CGI/R scripts when needed.
Unfortunately, some R packages contain functions that choose to output to stdout diagnostic information while running.
Since rApache uses stdout as part of the response, I'm curious about 'best practices' used by others to protect the stdout connection from such (undocumented) cases.
My default method for this is to sink() all stdout to stderr while building up a single response object, then briefly un-sink stdout, write the output, and re-sink stdout for any final cleanup.
The only negative part of that approach that I can see is the need to build that response object in-memory, rather than outputing the appropriate data online during computation.
Constantly sinking/unsinking for incremental pieces of the output lead to rather unpleasant code, however.
One could wrap calls in capture.output(), but that also tends to obfuscate the code.
What other approaches, if any, have y'all come up with?
Cheers!
-m