Skip Menu |
 

This queue is for tickets about the LWP-UserAgent-POE CPAN distribution.

Report information
The Basics
Id: 76125
Status: open
Priority: 0/
Queue: LWP-UserAgent-POE

People
Owner: Nobody in particular
Requestors: RCAPUTO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: shut down PoCo::Client::HTTP for prompt program exit
Download (untitled) / with headers
text/plain 1.3k
Hi, Mike! Changes to the POE::Component::Client::HTTP stack require an explicit shutdown to allow a prompt program exit. Here's a small test case someone brought to my attention in IRC. Some notes: 1. Without the "tick" timer, the session exits before a response can arrive. 2. Without the "shutdown" in _stop, the program will linger until sockets and resolvers time out in POE::Component::KeepAlive and POE::Component::Resolver, respectively. #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent::POE; use POE; my $ua = LWP::UserAgent::POE->new(); POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->delay(tick => 1); # turn it on test_get(); $_[KERNEL]->delay(tick => undef); # turn it off }, tick => sub { print "asynchronous timers working...\n"; $_[KERNEL]->delay(tick => 1); # repeat while we're here }, _stop => sub { # When we stop, shut down the UA's internal PoCo::Client::HTTP. # It doesn't seem to do that itself, which is probably a bug. # This is done with call() because messages post()ed from _stop # won't be dispatched to their destinations. $_[KERNEL]->call( $ua->{poco_alias}, "shutdown" ); }, }, ); POE::Kernel->run(); sub test_get { print "hello, world\n"; my $resp = $ua->get("http://www.yahoo.com/"); print $resp->content, "\n"; }
Download (untitled) / with headers
text/plain 836b
On Wed Mar 28 12:37:32 2012, RCAPUTO wrote: Show quoted text
> Changes to the POE::Component::Client::HTTP stack require an explicit > shutdown to allow a prompt program exit.
Hi Rocco, this would explain why my test suite has been hanging :). I'm wondering, though, if there's a better way to solve this within PoCo::Client::HTTP. I bet it's very confusing to a lot of users (just as I was confused) that they can't shut down their application without sending an explicit shutdown to some POE component they've started earlier. "Undef"ing the guard variable should just fold it nicely. Another thing I've noticed: PoCo::Client::HTTP no longer seems to process "file:///..." URLs correctly, but returns a 400 (bad request) on them regardless if the file exists in the filesystem or not. Do you know more about it? Thanks for your help ... -- Mike


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.