Sha256: 56fe721e169a958661083b6d72c6f5467c6e8c36573bb4f0ea2ab7e6b6a81246
Contents?: true
Size: 682 Bytes
Versions: 7
Compression:
Stored size: 682 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
7 entries across 7 versions & 1 rubygems