http://www.perlmonks.org?node_id=380936


in reply to Re^3: Thread::Pool and Template Toolkit
in thread Thread::Pool and Template Toolkit

Ok here a code snippet to demonstrate the issue. If I uncomment Thread::Pool I don't see anything in the web browser, but the logs don't show any error. As soon as I comment it out I see the expected template display:

CGI code
#!/usr/bin/perl -w use strict; use CGI; #use Thread::Pool; use Template; my $q = new CGI; print "Content-type: text/html\n\n"; my $file = 'template.html'; my $vars = { message => "Hello World\n" }; my $template = Template->new({ INCLUDE_PATH => $ENV{DOCUMENT_ROOT} . '/t +emplates' }); $template->process($file, $vars) || die "Template process failed: ", $template->error(), "\n";


template.html:
<html lang="en"> <head> <title>Template Thread Test</title> </head> <body> This is a test, [% message %] </body> </html>

Replies are listed 'Best First'.
Re^5: Thread::Pool and Template Toolkit
by Joost (Canon) on Aug 07, 2004 at 20:25 UTC
    Well.. I can reproduce the problem. w/ perl 5.8.5, Thread::Pool v0.32 and TT v2.14

    #!/usr/local/bin/perl -w use strict; use CGI; use Thread::Pool; use Template; my $q = new CGI; print "Content-type: text/html\n\n"; my $file = 'template.html'; my $vars = { message => "Hello World\n" }; my $template = Template->new({ INCLUDE_PATH => './' }); $template->process($file, $vars) || die "Template process failed: ", $template->error(), "\n"; __END__ Content-type: text/html
    No error messages whatsoever.

    Interestingly, replacing the template->process() call with

    $template->process($file, $vars,'output.html')
    gives the error message
    Could not find file for 'output.html' at /usr/local/lib/perl5/site_per +l/5.8.5/load.pm line 209.
    (load.pm is loaded by Thread::Pool).

    Maybe liz knows more.

Re^5: Thread::Pool and Template Toolkit
by BrowserUk (Patriarch) on Aug 07, 2004 at 19:37 UTC

    May I ask how you installed Thread::Pool?


    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
      CPAN shell from Linux:
      cpan>install Thread::Pool
      It prepended the other necessary modules(Thread::Serialize, Tie, Conveyor, etc..) and downloaded and installed them as well. I did see the Scalars leaked: 1 message as the install was going through its tests, but other than that it looked ok. Do you think I should get the modules individually and install them one at a time?

        I've had several attempts at installing Thread::Pool, both using CPAN.pm and manually, and I cannot persuade Thread::Tie to pass it test suite amongst other failures. Maybe that's a win32 thing, but maybe not.

        However, I'd have to conclude that Thread::Pool is not ready for prime time. And unless liz pops her head up to say otherwise, as far as I know, she is no longer actively developing her raft of Thead::* modules.

        That said, I've never found the need for this level of abstraction with threads. Creating and managing a pool of threads is so easy to do natively--usually 5 to 10 lines of code--that I would probably never use (or create) a tool to do this for me.

        Please do not construe this to mean that threads are broken or unusable. That would be like downloading Math::BigInt::Roman, having problems with it, and declaring that Perl can't count.

        Since 5.8.3, I've found iThreads to be extremely stable and usable, though they do require a little thought and care to use well (no surprise there). On my platform, I would say they are production ready, but your milage may vary.


        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