I've seen a couple posts on this subject but no replies. I
need to cut off a request with at least 98% accuracy at 2
seconds. For a particular URL (which I can't reveal,
unfortunately), LWP's timeout doesn't always do the trick,
and even wrapping an eval/ALRM around it fails to the tune
of 50%. Stranger still, when the timeout /does/ finally come
around, it rings on 5 second intervals, no matter /what/ the
timeout was set to. Here's the sample code:
use Time::HiRes qw(alarm sleep);
...
my $t0 = [gettimeofday];
my $res;
eval {
local $SIG{ALRM} = sub { die "alarm timeout" };
alarm($timeout);
$res = $ua->get($np_key_url);
alarm(0);
};
alarm(0);
my $real_time_taken = &tv_interval($t0);
Sample output from my test run:
500 alarm timeout Fetch took 1.000 seconds.
500 alarm timeout Fetch took 1.003 seconds.
500 alarm timeout Fetch took 1.000 seconds.
500 alarm timeout Fetch took 5.018 seconds.
500 alarm timeout Fetch took 1.003 seconds.
500 alarm timeout Fetch took 15.149 seconds.
Does this sound like an issue with LWP, IO:Socket, perl, or
RedHat? I'm absolutely dying, here. I'm using:
LWP::UserAgent 2.004
Time::HiRes 1.51
IO 1.20
IO::Socket 1.27
IO::Socket::INET 1.26
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.9-e.25smp, archname=i686-linux
uname='linux 2.4.9-e.25smp #1 smp fri jun 6 17:01:35 edt 2003 i686
unknown '
config_args='-de'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
____________________________________________________________
Eamon Daly