Name
timeout — Time out a lengthy procedure
Synopsis
Times out a lengthy procedure or those that continue execution beyond a set duration.
Required Library
require ‘timeout’
Function
timeout(
sec
) {
...
}
Executes the block and returns
true
if the block execution terminates successfully prior to elapsing of the timeout period, otherwise immediately terminates execution of the block and raises aTimeoutError
exception.require 'timeout' status = timeout(5) { # something that may take time }
Get Ruby in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.