richfitz / rcmdshlib

:construction_worker: Build shared libraries for R, from R
Other
1 stars 0 forks source link

Port from system2 to callr/processx #5

Open richfitz opened 7 years ago

richfitz commented 7 years ago

@gaborcsardi; to use callr but keep output interleaved correctly, would this be reasonable? It empirically works (OSX) but don't know how portable this will be

  log <- tempfile()
  res <- callr::rcmd("SHLIB", "file.c", stdout = log, stderr = log)
richfitz commented 7 years ago

Actually, it looks like this goes nicely with the callback argument

gaborcsardi commented 7 years ago

I cannot magically make stdout and stderr interleaved correctly, unfortunately. As soon as you redirect them to separate connections, there is no way to tell which happened first.

And you often do want them in different connections, because you want to know what was on the output, what was on the error.

What I could do is

  1. provide an option that redirects stdout/stderr into the same connection, and then they'll be in the right order. But we will not know what was the output and what was the error.
  2. work out a way to make the worker process smarter, and label the lines that go to stdout or stderr.

It empirically works (OSX) but don't know how portable this will be

It only works by chance, I think.

gaborcsardi commented 7 years ago

Actually, it looks like this goes nicely with the callback argument

There is no guarantee that the callbacks will be called in the right order. :(

richfitz commented 7 years ago

There is no guarantee that the callbacks will be called in the right order. :(

Sadface indeed.

provide an option that redirects stdout/stderr into the same connection, and then they'll be in the right order. But we will not know what was the output and what was the error.

This would be a useful option

gaborcsardi commented 7 years ago

But actually, if you are happy with system2, then maybe we do not need to use processx.

richfitz commented 7 years ago

That seems like the simplest solution, and it does seem to work. But there is duplication there with callr so it would be nice to port that over once it can support it

gaborcsardi commented 7 years ago

Of course system2 does not tell you what was on stdout and what on stderr, but seems like you don't need this. :)

gaborcsardi commented 7 years ago

https://github.com/r-pkgs/processx/issues/47