I am using Perl library HTTP::Async as follows:
use strict;
use warnings;
use HTTP::Async;
use Time::HiRes;
...
my $async = HTTP::Async->new( ... );
my $request = HTTP::Request->new( GET => $url );
my $start = [Time::HiRes::gettimeofday()];
my $id = $async->add($request);
my $response = undef;
while (!$response) {
$response = $async->wait_for_next_response(1);
last if Time::HiRes::tv_interval($start) > TIME_OUT;
}
...
When while loop timeout and script ends, I experience the the following error message:
HTTP::Async object destroyed but still in use at script.pl line 0
HTTP::Async INTERNAL ERROR: 'id_opts' not empty at script.pl line 0
What are my options? How can I “clean-up” HTTP::Async object if still in use, but not needed anymore?
I would suggest that you
removeincomplete requests, but the module does not provide any interface to do so.Option 1: Add removal functionality.
Add the following to your script:
You should contact the author and see if he can add this feature.
$idis the value returned byadd.Option 2: Silence all warnings from the destructor.
If you’re ok with not servicing all the requests, there’s no harm in silencing the warnings. You can do so as follows:
Note that this will silence all warnings that occur during the object’s destruction, so I don’t like this as much.