module Dump::ContiniousTimeout
Timeout if does not finish or defer in requested time
Public Class Methods
timeout(sec) { |deferer| ... }
click to toggle source
# File lib/dump/continious_timeout.rb, line 23 def self.timeout(sec) x = Thread.current y = Thread.start do 1.times do begin sleep sec rescue RestartException retry end end x.raise TimeoutException, 'execution expired' if x.alive? end yield Deferer.new(y) ensure y.kill if y && y.alive? end