Subject: | resolve() on shutdown resolver |
I catch exception "resolve() on shutdown resolver" when run my test.
If I add param
ConnectionManager => POE::Component::Client::Keepalive->new(resolver =>
POE::Component::Resolver->new(idle_timeout => 1),)
test will pass.
Subject: | for_cpan4.t |
#!/usr/bin/perl
use utf8;
use strict;
use warnings;
use Data::Dumper;
use POE 1.350;
use POE::Component::Client::HTTP 0.946;
use POE::Component::Client::Keepalive 0.271;
use HTTP::Request::Common qw(GET HEAD);
use HTTP::Cookies;
use Test::More tests => 3;
use Scalar::Util qw(weaken);
my @domains = ('yandex.com', 'google.com');
check();
@domains = ('gmail.com');
check();
sub check {
POE::Component::Client::HTTP->spawn(
Alias => 'ua',
FollowRedirects => 3,
Timeout => 3,
Agent => '',
Streaming => 0,
CookieJar => HTTP::Cookies->new(),
);
for (1..2) {
POE::Session->create(
inline_states => {
_start => sub {
my $kernel = $_[KERNEL];
$kernel->yield('next_domain');
},
_stop => sub {},
response => \&response,
next_domain => \&next_domain,
},
);
}
POE::Kernel->run();
}
exit;
sub response {
my ($kernel, $request_packet, $response_packet) = @_[KERNEL, ARG0, ARG1];
my $http_request = $request_packet->[0];
my $tag = $request_packet->[1];
my $http_response = $response_packet->[0];
is($http_response->code, 200, $tag->{domain});
$kernel->yield('next_domain');
}
sub next_domain {
my $kernel = $_[KERNEL];
if (@domains) {
my $domain = shift @domains;
my $header = [TE => 'chunked,identity', Connection => "close"];
my $url = "http://$domain/";
my $request = HTTP::Request->new( 'GET', $url, $header);
$kernel->post( "ua" => "request", "response", $request, {domain=>$domain});
}
}