Home : General : Perl Programming :

General: Perl Programming: problem with multithreaded web client: Edit Log

Here is the list of edits for this post
problem with multithreaded web client
this is my first time playing with forked processes and this script starts having issues when I run more than 10 or 20 threads... if I run a high number of threads if one process has a problem then all of them die... i need to figure out either my problem or how to debug this kind of thing. also, is there a better way to be doing this? I am trying to make a load testing application to stress test servers in a QA environment.

------------------

#!perl.exe

use LWP;
use HTML::Parse;
use HTML::Element;
use HTTP::Request;
use Thread qw(async);
use strict;

printf "\n-------\n";

my @children;
for (1..4)
{
$children[$i] = async {
getIt();
};
}

for (my $i=0;$i<4;$i++)
{
$children[$i]->join();
}

sub getIt()
{
my $ua = LWP::UserAgent->new();
$ua->agent("MyApp/0.1 ");
my $url = 'http://web.pdx.edu/~jonw';
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
my $code = $res->code;
my $content = $res->content;
if ($res->is_error())
{
printf "%s\n", $res->status_line;
}
else
{
my $content = $res->content();
}
printf "$content\n-------\n";
}

Last edited by:

mozkill: Apr 18, 2003, 3:36 PM

Edit Log: