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.

In reply to LWP::Parallel::UserAgent discard_entry does not delete entry objects by perlmonkey2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.