Вск Апр 29 19:29:49 2012, RCAPUTO писал:
Show quoted text> On Sat Apr 14 08:33:40 2012, sergei wrote:
> > when i use poe-component-client-http for check domain by ip, my
> program
> > doesn't exit. Because in this way we don't send request to resolver
> and
> > resolver doesn't call $kernel->delay(sidecar_eject => $heap-
> >{idle_timeout})
> > I solved this problem, by calling $keepalive_obj->shutdown() in my
> program.
> > I will be happy if resolver could destroyed whithout explicit call
> shutdown
>
> If you shutdown POE::Component::Client::HTTP, it should shutdown
> Resolver and KeepAlive for
> you. Your program should exit quickly after that.
>
> In other words, you should not need to shut down KeepAlive and
> Resolver explicitly. Just
> Client::HTTP when you're done with that.
>
> Is this good enough?
Let's I show my problem.
#!/usr/bin/perl -w
use utf8;
use strict;
use warnings;
use Data::Dumper;
use POE 1.350;
use POE::Component::Client::HTTP 0.944;
use POE::Component::Client::Keepalive 0.270;
use HTTP::Request::Common qw(GET HEAD);
use HTTP::Cookies;
$SIG{__WARN__} = sub {
my $str = shift;
warn scalar(localtime)." $str";
};
my $pool = POE::Component::Client::Keepalive->new(
keep_alive => 3,
max_open => 2,
max_per_host => 2,
timeout => 7,
resolver => POE::Component::Resolver->new(
max_resolvers => 1,
idle_timeout => 11,
),
);
POE::Component::Client::HTTP->spawn(
Alias => 'ua',
FollowRedirects => 3,
Timeout => 13,
MaxSize => 1024,
Agent => '',
ConnectionManager => $pool,
Streaming => 0,
CookieJar => HTTP::Cookies->new(),
);
foreach my $i (1..2) {
POE::Session->create(
inline_states => {
_start => sub {
my $header = [TE => 'chunked,identity', Connection => "close"];
my $domain = '127.0.0.1:36333';
my $url = "http://$domain/$i";
my $request = HTTP::Request->new( 'GET', $url, $header);
$poe_kernel->post( "ua" => "request", "response", $request, {domain=>$domain, i => $i});
},
_stop => sub {},
response => \&response,
},
);
}
POE::Kernel->run();
warn 1;
exit;
sub response {
my ($request_packet, $response_packet) = @_[ARG0, ARG1];
my $http_request = $request_packet->[0];
my $tag = $request_packet->[1];
my $http_response = $response_packet->[0];
warn Dumper $tag;
warn Dumper $http_response;
}