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

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

First, Marc Langheinrich did a great job on this module. It is going to meet my needs perfectly and allows a single thread to access hundres of webpages at the same time, just as advertised.

But I've ran into an issue. I'm not sure if it is because I've created a wrapper object that inherits from LWP::Parallel::UserAgent or what, but for some reason the method discard_entry doesn't appear to be deleting the entry objects. I've overloaded the on_return method and have this:

sub on_return { my ($self, $request, $response, $entry) = @_; .....Do some work, process data, register regex'd urls...... $self->discard_entry($entry);
This should work, but when I Data::Dump::dump the LWP object after that call, not only is the entry still there, but the response and request objects it contained.

The discard_entry code is as follows:

sub discard_entry { my ($self, $entry) = @_; LWP::Debug::trace("($entry)") if $entry; # Entries are added to ordpend_connections in $self->register: # push (@{$self->{'ordpend_connections'}}, $entry); # # the reason we even maintain this ordered list is that # currently the user can change the "in_order" flag any # time, even if we already started 'wait'ing. my $entries = $self->{ordpend_connections}; @$entries = grep $_ != $entry, @$entries; $entries = $self->{entries_by_requests}; delete @$entries{grep $entries->{$_} == $entry, keys %$entries}; $entries = $self->{entries_by_sockets}; delete @$entries{grep $entries->{$_} == $entry, keys %$entries}; return; }
When I test this on my own, the return from keys aren't blessed as a proper HTTP::Response type, so I don't know if the error is in the library or in how I'm using it.