Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by Wonko the sane (Deacon)
on Mar 25, 2004 at 19:11 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found