Munin::Common::Timeout(3pm)

Munin::Common::Timeout3pm

Run code with a timeout. may nest.

Usage

 use Munin::Common::Timeout;
 do_with_timeout(50, sub {
     # ...
        do_with_timeout(5, sub {
                # ...
                # ...
        });
     # ...
 });

Overview

See also Time::Out, Sys::AlarmCall

Subroutines

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.

Releases

9 releases since Debian 6.0 (Squeeze); the text changed 8 times.

  1. 6.0
  2. 7
  3. 8
  4. 9
  5. 10
  6. 11
  7. 12
  8. 13
  9. Arch

From munin-node 2.0.76-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.