multithreading - Perl - Using LWP in multithread program -


here's code:

use lwp; use threads;  use strict; use warnings;  @thrds;  (1..100) {     push @thrds, threads->create( 'doit' ); }  (@thrds) {     $_->join(); }  sub doit {     lwp::useragent->new->get("http://dx.doi.org/10.1002/aoc.1067"); } 

i'm using windows 7 x64 , activeperl 5.20.2 x64, tried strawberryperl. i've got bunch of errors:

thread ... terminated abnormally: can't locate object method "_uric_escape" via package "uri" @ .../uri.pm line 81

string found operator expected @ (eval 10) line 8, near "croak 'usage: $io->getlines()'"

(do need predeclare croak?)

if add

sleep 1; 

before

push @thrds, threads->create( 'doit' ); 

it'll ok.

what's problem?

i'm not sure why, there seems problems dealing dynamically-loaded modules. explicitly loading them before thread creation solves problem. in other words, add following:

use carp qw( ); use uri  qw( ); 

Comments

  1. Hi!
    Add next line fix this error for me:

    use IO::Handle;

    ReplyDelete

Post a Comment

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

Revit Family Rename in a project -