Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How to make a time-out with LWP::Simple

by Wonko the sane (Deacon)
on Mar 25, 2004 at 19:11 UTC ( #339840=note: print w/ replies, xml ) Need Help??


in reply to How to make a time-out with LWP::Simple

Hello,

I am not sure how you could catch a timeout set in UserAgent, but wrapping your call in an eval, with an alarm, would
probably fit your needs.

$SIG{ALRM} = sub { die q{timeout} }; URL: foreach my $url ( @urls ) { alarm( 2 ); # amount of time allowed for call. eval { my $page = get( $url ); # LWP::Simple call }; if ( $@ =~ /^timeout/ ) { print qq{Skipping this one, timed out.\n}; next URL; } # Do something with successful call. }

Wonko


Comment on Re: How to make a time-out with LWP::Simple
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://339840]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2015-07-08 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls