table of contents
other versions
- stretch 2.0.33-1
- testing 2.0.49-1
- stretch-backports 2.0.47-1~bpo9+1
- unstable 2.0.49-1
Munin::Common::Timeout(3pm) | User Contributed Perl Documentation | Munin::Common::Timeout(3pm) |
NAME¶
Munin::Common::Timeout - Run code with a timeout. May nest.SYNOPSIS¶
use Munin::Common::Timeout; do_with_timeout(50, sub { # ... do_with_timeout(5, sub { # ... # ... }); # ... });
DESCRIPTION¶
See also Time::Out, Sys::AlarmCallSUBROUTINES¶
- do_with_timeout
-
my $finished_with_no_timeout = do_with_timeout($seconds, $code_ref) or die "Timed out!";
Executes $block with a timeout of $seconds. Returns the return value of the $block if it completed within the timeout. If the timeout is reached and the code is still running, it halts it and returns undef.
NB: every $code_ref should return something defined, otherwise the caller doesn't know if a timeout occurred.
Calls to do_with_timeout() can be nested. Any exceptions raised by $block are propagated.
2019-03-11 | perl v5.24.1 |