Sha256: 49b9d6acba52c2d326662b0131f3f35fc6668eea0e3e8e82a4e67cdbdcb1293d
Contents?: true
Size: 681 Bytes
Versions: 4
Compression:
Stored size: 681 Bytes
Contents
# frozen_string_literal: true require 'timeout' # Timeout extensions module ::Timeout # Sets a timeout for the given block. This method provides an equivalent API # to the stock Timeout API provided by Ruby. In case of a timeout, the block # will be interrupted and an exception will be raised according to the given # arguments. # # @param sec [Number] timeout period in seconds # @param klass [Class] exception class # @param message [String] exception message # @return [any] block's return value def self.timeout(sec, klass = Timeout::Error, message = 'execution expired', &block) cancel_after(sec, with_exception: [klass, message], &block) end end
Version data entries
4 entries across 4 versions & 1 rubygems