Sha256: 92358c707709d27579752f8c8f621a4b7eb8a920a1aa98fe005975e5442e987d
Contents?: true
Size: 708 Bytes
Versions: 4
Compression:
Stored size: 708 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 # @yield [] code to run # @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