class Async::Reactor
def timeout(duration, exception = TimeoutError)
-
duration
(Integer
) -- The time in seconds, in which the task should
def timeout(duration, exception = TimeoutError) backtrace = caller fiber = Fiber.current timer = self.after(duration) do if fiber.alive? error = exception.new("execution expired") error.set_backtrace backtrace fiber.resume error end end yield ensure timer.cancel if timer end