in reply to threaded sub cannot access external module

You don't show any relevant code, but guessing from iehistory, you might be trying to use (Windows) objects created outside the thread within another thread. That will likely give you nothing but grief.

Replies are listed 'Best First'.
Re^2: threaded sub cannot access external module
by mantyBBQ (Initiate) on Apr 19, 2010 at 15:51 UTC

    I pasted much more code of the code...if it helps the relevance of my question, great. If not, I may have to trace Thread::Pool::Simple.

      You have posted some parts, and I still cannot conveniently reproduce your problem. This makes it hard for me to help you. But at least one of my guesses is that you are loading the modules later than you create your threads. Maybe the modules are not available in the other namespaces threads. Try loading the modules before you create your threads.

        Corion...even though you didn't have the code needed to test, you did solve my problem...Vielen Dank! I now run a "dynamic" require within each thread...and all is well:

        # we have the artifact here, it's verified so we just need to parse it sub parse_artifact() { my ($format, $file) =@_; my $t_line; my @args = undef; # this thread's scope needs to re-load the file-specific input + module my @temp = split(/::/, $format->{'name'}); my $formatInput = $temp[2] . ".pm"; my $thread_format_dir = Log2t::Common::get_directory(); $thread_format_dir .= '/Log2t/input/'; require $thread_format_dir . '/' . $formatInput;

        I am seeing ~25% speed increases on my test machine already...thanks for your help