Caveat: I know nothing about RSPerl, other than it embeds one interpretter in the other.
Since each Perl thread starts a new interpretter, its unclear whether an R interpretter created in the main thread will get cloned into all the children,
or each child will get a brand new R interpretter instance.
Assuming you revert to the original approach, you might try cranking up the
per-thread stack size, and see if that corrects the error message. Note that doing so will reduce the number of threads you can start.
Perl Contrarian & SQL fanboy
| [reply] |
I couldn't find the R or the RReferences module on cpan. There probably is a way to make it work with threads, but reading the reviews of Statistics::R module, it is problem prone on it's own, even without threads. Since it involves a "shell" you may need some kind of pty, or pipes, to run it from Perl thru IPC. See if you can get it to work thru a forking mechanism first, until you get a handle on what is exactly happening, and then try to convert to threads.
| [reply] |
I was just meditating last night, and thought about your problem. I had a thought( better duck :-) ). If the RSPerl is an interpreter, which you send commands to stdin and get results out of stdout, you probably should run it thru IPC::Open3. I have sample code below
#!/usr/bin/perl
use warnings;
use strict;
use IPC::Open3;
$|=1;
#my $pid=open3(\*IN,\*OUT,\*ERR,'/bin/bash');
my $pid=open3(\*IN,\*OUT,0,'/bin/bash');
# set \*ERR to 0 to send STDERR to STDOUT
my $cmd = 'date';
#my $cmd = 'top';
#send cmd to bash
print IN "$cmd\n";
#getresult
my $result = <OUT>;
print $result;
Now you should be able to do a similar thing with the RSPerl interpreter. Of course, in a real script, you may want to separate stdout and stderr, and use IO::Select. Search for examples of IPC::Open3 for more detailed usage. Now, once you get IPC::Open3 to run the interpreter, you can put the code into a thread, and pass in strings to be eval'd thru ther shared variable mechanism.
| [reply] [d/l] |
Thanks to everyone for your input. I've solved the problem a slightly different way. I was able to set up a socket connection between R & Perl. If anyone is interested in the Perl or R code that accomplishes this, please let me know.
| [reply] |
Hi, could you please share the code with us all? I am a biologist used to working in R environment for my statistical analysis. But, now I have to call my .R files from perl. I have tried using RSperl, but it doesn't seem to support source("filename.R") function. Any take on this? Your comments are highly appreciated.
| [reply] |
Yes, I am interested in the Perl and the R code.
Thank you very much.
| [reply] |
i would be very interested in this code. can you post it up on here or send it to me directly?
| [reply] |