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