Beam::Runnable::Timeout::Alarm - Use `alarm` to set a timeout for a command
version 0.012
### In a Runnable module package My::Runnable::Script; use Moo; with 'Beam::Runnable', 'Beam::Runnable::Timeout::Alarm'; has '+timeout' => ( default => 60 ); # Set timeout: 60s sub run { } ### In a container config file runnable: $class: My::Runnable::Script $with: - 'Beam::Runnable::Timeout::Alarm' timeout: 60
This role adds a timeout for a runnable module using Perl's alarm() function. When the timeout is reached, a warning will be printed to STDERR and the program will exit with code 255.
STDERR
255
The time in seconds this program is allowed to run. This can include a decimal (like 6.5 seconds).
6.5
A callback to be run when the timeout is reached. Override this to change what warning is printed to STDERR and what exit code is used (or whether the process exits at all).
This role wraps the run method of your runnable class to add the timeout.
run
Beam::Runnable, "alarm" in perlfunc, Time::HiRes
Doug Bell <preaction@cpan.org>
This software is copyright (c) 2016 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Beam::Runner, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Beam::Runner
CPAN shell
perl -MCPAN -e shell install Beam::Runner
For more information on module installation, please visit the detailed CPAN module installation guide.