perldragon80 has asked for the wisdom of the Perl Monks concerning the following question:

Wise Ones,
I ask of you a question about a strange phenomenon I have run into. I am trying to use Thread::Pool to manage my worker threads who go out and get stat info from routers. The threads do their work, return the appropriate data and pass that data onto the Template Toolkit process function as a Hash of Hashes.


The problem is that after the data is returned (and I debugged it to make sure the data was indeed returned), the process spits out no values for anything in my template and nothing shows up in the browser(except the background page color). I remove the Thread::Pool module and use the threads module for threading without management and voila, HTML is back.

Does anyone have any idea why this would happen?
As an aside the background color is printed and I don't get any server log errors and I can even hear the server doing processing work while the threading happens, the page just doesn't get displayed. I even put the Thread::Pool code into a standalone script just to make sure I was getting the proper values and returning the appropriate information, and it looked fine.......HMMMMM.

Perl version:5.8.5, with the latest TT and Thread::Pool modules, as well as Apache 2.0.50.

Replies are listed 'Best First'.
Re: Thread::Pool and Template Toolkit
by BrowserUk (Patriarch) on Aug 07, 2004 at 05:49 UTC

    In addition to anonymonk's wise council, be aware. There appear to be two quite different versions of Thread::Pool on cpan. version 0.1 was designed for use with 5005threads (pthreads) and almost certainly won't do anything useful in conjunction with iThreads as found in perls 5.8.0 and later.

    The other version is liz' v0.32. If this is the version you are trying to use, please read the very prominent "Note of caution" at the top of the "Description" section.

    Beyond that, my copy of of Algoritm::ESP seems to be acting up...can you help?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
      Version is v0.32, and I have compiled perl 5.8.5 with threading, just to set your minds at ease.

      Ok, so apparently people aren't enthused with vague problem listings, and poor problem descriptions, but I thought this was the monastery....don't people go to places of faith and wisdom with the silliest of questions hoping for an answer that can't possibly be given by someone who isn't as reverant or intelligent as they would have you believe???....Anyway, I digress.


      I suppose my situation isn't easily explained or easily understood, but I will try a little better next time, after reading the "how not to get chastised" help faq (for the 2nd time no less, you would think I would learn my lesson) :(...

        Threading problems are notoriously difficult and on top of that Perl's implementation is probably still buggy. It's very hard to give you a helpful answer without seeing the code of the script and the template(s).

        I think the best thing for you to do is to cut the offending program back to the smallest example that still demonstrates the bug. If the problem isn't clear by then, feel free to post the code here for people to look at. I'm sure the monks will be happy to help you out.

Re: Thread::Pool and Template Toolkit
by Anonymous Monk on Aug 07, 2004 at 03:22 UTC
    Yes, its because you have an error on line 36. We are all mind readers here, enjoy your stay
      Ah, the sting of an anonymous slap!
      Well, to add more info for all you mind readers out there, I have actually found that the problem seems to lie with the combo of the Template Module and the Thread:Pool module. All I have to do is comment out "use Thread::Pool" and the non thread areas of the webapp work and the templates are all processed and displayed. I know, this isn't much to go on, but perhaps someone out there has seen something similar....