Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: enforce timeout in loop

by perlmonkey (Hermit)
on Sep 22, 2003 at 05:28 UTC ( #293088=note: print w/replies, xml ) Need Help??


in reply to enforce timeout in loop

Follow the example in the perldoc page for alarm. Change your for loop to look like:
foreach my $sleepval (@sleepvals) { eval { local $SIG{ALRM} = sub { die }; alarm 3; sleep($sleepval); }; print strftime "%H:%M:%S", localtime; print "\n"; }

Replies are listed 'Best First'.
Re: Re: enforce timeout in loop
by semio (Friar) on Sep 22, 2003 at 15:48 UTC
    ++perlmonkey. beautiful. This is exactly what I was looking for.

    cheers, -dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://293088]
help
Chatterbox?
[Mr. Muskrat]: (considered) Re^3: Please help with Regexp::Common needs to be reparented to Re^2: Please help with Regexp::Common
[Mr. Muskrat]: Is it just me or does that timeout issue seems to be happening more often lately?
[Corion]: Mr. Muskrat: I'm not sure if it really happens more often, but I don't exactly know either
[LanX]: yep
[LanX]: more often for some weeks now
[Corion]: I think I'll have to manually (as god) intervene with that node, as the simple reparenting didn't seem to fix the parent/child relationship of the nodes

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2017-01-19 16:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.