in reply to Hard timeout for LWP::UserAgent or similar
Is it possible to combine LWP::UserAgent with an alarm call to force a timeout? I've tried this but w/o success.
When alarm doesn't work (for whatever reason), I usually fork another process and have the parent kill the child (which would do the actual work) after a predefined time.
Something like this:
use LWP; for (...) { my $pid = fork(); die "couldn't fork" unless defined $pid; unless ($pid) { my $ua = LWP::UserAgent->new(); my $response = $ua->get('http://...'); ... exit; } else { select undef, undef, undef, 0.25; kill 15, $pid; } }
(you might want to use a more sophisticated timing/killing method...)
|
|---|