From 37e59f5583c781e98f41608251e094377237a133 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 19 Apr 2010 03:46:17 +0000 Subject: [PATCH] * lib/timeout.rb (Timeout#timeout): propagate errors to the caller. [ruby-dev:41010]' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/timeout.rb | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1126767e6e..524a84c908 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 19 12:46:15 2010 Nobuyoshi Nakada + + * lib/timeout.rb (Timeout#timeout): propagate errors to the + caller. [ruby-dev:41010]' + Mon Apr 19 00:27:03 2010 NARUSE, Yui * vm_method.c (rb_add_method_def): workarond fix for redefinition diff --git a/lib/timeout.rb b/lib/timeout.rb index 1dccc57477..297b76936c 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -46,8 +46,13 @@ module Timeout begin x = Thread.current y = Thread.start { - sleep sec - x.raise exception, "execution expired" if x.alive? + begin + sleep sec + rescue => e + x.raise e + else + x.raise exception, "execution expired" if x.alive? + end } return yield(sec) rescue exception => e