Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 taking refuge in the Monastery: (4)
As of 2014-07-26 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (179 votes), past polls