I'm creating a parallel link checker in mod_perl using
LWP::Parallel::UserAgent.

Are there going to be any problems by instantiating the PUA as a class
variable? I only see the object being created when apache starts - not
when new child proccess are created or when there is a reload - does this
mean that all the process's will share the same PUA?  As I've run this on
several larger sites - I've noticed my memory us has sometimes pegged up
to 11M, and then never gets smaller. Any ideas?

For example:

use strict;
use vars qw($VERSION $PUA);
use LWP::Parallel::UserAgent qw(:CALLBACK);
use HTTP::Request;
use HTTP::Response;

unless( ref $PUA ) {
  $PUA = LWP::Parallel::UserAgent->new();
  warn("$$ created new PUA");
}

sub handler ($$) {
  $PUA->initialize();
  ...
  # Create a closure to store $self
  my $callback_parse = sub { $self->callback_parse(@_) };
  foreach (@requests) {
    $PUA->register($request, $callback_parse );
  }
  $self->body($r);
  return OK;
}

sub body {
  my($self, $r) = @_;
  $PUA->wait();
  ...

}A



Reply via email to