Munin::Common::Timeout.3pm

Langue: en

Version: 2010-08-13 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Munin::Common::Timeout - Run code with a timeout.

SYNOPSIS

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

DESCRIPTION

See also Time::Out, Sys::AlarmCall

SUBROUTINES

do_with_timeout
  my $finished_with_no_timeout = do_with_timeout($seconds, $block)
      or die "Timed out!";
 
 

Executes $block with a timeout of $seconds. Returns true if it completed within the timeout. If the timeout is reached and the code is still running, it halts it and returns false.

Calls to do_with_timeout() can be nested. Any exceptions raised by $block are propagated.

reset_timeout
  reset_timeout();
 
 

When called from within $block, resets its timeout to its original value.