google-code-export / rcaller

Automatically exported from code.google.com/p/rcaller
Other
1 stars 0 forks source link

runAndReturnResultOnline() can hang... #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I've run into a situation where RCaller hangs using 2.4.

I took one of your test cases and made some changes to run locally and I 
changed the run type to be runAndReturnResultOnline.

--------
RCaller rcaller = new RCaller();
rcaller.setRscriptExecutable(<mydir>);
rcaller.setRExecutable(<mydir>);
RCode code = new RCode();
code.clear();
code.addIntArray("x_i", new int[]{1, 2, 3, 4, 5, 6});
code.addRCode("x_i <- x_i * 2");
rcaller.setRCode(code);
rcaller.runAndReturnResultOnline("x_i");
int[] actual = rcaller.getParser().getAsIntArray("x_i");
int[] expected = new int[]{2, 4, 6, 8, 10, 12};

rcaller.deleteTempFiles();
--------

the above works as expected. However, if I comment out the statement 
"code.addIntArray("x_i", new int[]{1, 2, 3, 4, 5, 6})", I expected to see a 
parsing error thrown, but instead the program hangs and I get no parsing error. 
If instead I run as .runAndResultResult() a parsing error is thrown.

I found this when I forgot to add the int array to the RCode object. I'm using 
RCaller in an interactive application, so I need to catch user errors in 
specifying the script.

Thanks for any suggestions.

Original issue reported on code.google.com by cszamu...@gmail.com on 25 Jun 2014 at 6:30

GoogleCodeExporter commented 9 years ago
There are a few things I've discovered in trying to solve this problem. The 
class RCaller could benefit from a couple of changes:

the method runAndReturnResultOnline loops until a clean parse is established. 
Unforunately, it currently appends the output file command on each iteration, 
so they build up in the script that is sent to R.  I modified this loop to only 
append the most current output file name.  This helps.

The code currently does not test for an outputFile length of 0 after it exits 
from the "processKilled" loop, so if the maxWaitTime is achieved then it hangs. 
 Testing for outputFile.length() == 0 should throw an exception and let the 
handleRFaileure deal with it.

So, with these changes I've been able to run successfully while dealing with 
RScript errors.

Original comment by cszamu...@gmail.com on 26 Jun 2014 at 9:21