Hi all, I'm trying to use the RSPerl module in a script that uses threads. I am able to call R functions without a problem when I don't use threads. However, using threads, I get varying errors depending on how I call the R functions. If I call the R::initR function in the "boss" thread and then try to call R functions from a "worker" thread, I get the following error: Error: C stack usage is too close to the limit Caught error in R::call() However, if I move the "use" declarations for R & RReferences to the worker thread, along with the initR call, I get this: Fatal error: R home directory is not defined I've attached some code for your reference. Is there any way to get this module working with Perl threads? Thanks in advance for your help. -Jay #!/usr/bin/perl use warnings; use strict; #use R; #use RReferences; #&R::initR("--silent"); use threads; use threads::shared; use Thread::Queue; our $queue : shared = Thread::Queue->new; our $hold : shared; my $thr = threads->new (\&command_runner); $hold =1; $queue->enqueue("ls"); while ($hold) { sleep(1); } $queue->enqueue("end"); $thr->join(); # Thread for processing functions sub command_runner { use R; use RReferences; &R::initR("--silent"); my $run = 1; # run until return while ($run) { # This call will block until the main thread sends the job my $job = $queue->dequeue; print "j: $job\n"; if ($job eq "ls"){ R::ls(); } elsif ($job eq "end") { $run = 0 } { lock $hold; $hold = 0; } } } [[alternative HTML version deleted]]