Forum Moderators: coopster & phranque

Message Too Old, No Replies

lwp, eval SIGALRM and ->timeout(xx)

         

littleman

7:13 pm on Jul 12, 2001 (gmt 0)



I've been trying to build a timeout routine for LWP that consistently works for a while now. I am using proxies and every now and then a routine will just hang until I go in and kill the pid. Anyone else have any luck?

sugarkane

8:02 pm on Jul 12, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know what code you're using, but it's possible that the LWP timeout is being confused by a response from the proxy?

This should work consistently as it bypasses the LWP timeout, but I've not tried it through a proxy so YMMV...

eval {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm $timeout;
$req=HTTP::Request->new(GET => $url);
alarm 0;
};

littleman

9:22 pm on Jul 12, 2001 (gmt 0)



Thanks Sugarkane. I have tried using an eval like the one you put in many times, it should do the trick but it doesn't always. I did some poking in news groups and Gisle Aas said that there is a bug in IO pre 1.2 that could cause this. So, I installed the new IO module and it is working now. Thanks for the help.

sugarkane

9:28 pm on Jul 12, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the IO heads up...