diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-19 03:46:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-19 03:46:17 +0000 |
commit | 37e59f5583c781e98f41608251e094377237a133 (patch) | |
tree | 63a14f8c05e211e5fe048e06728ded36d0d7ba4d | |
parent | cd08b1cbff1bc8f60c64ded8a21d57d1c58eea18 (diff) | |
download | ruby-37e59f5583c781e98f41608251e094377237a133.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/timeout.rb | 9 |
2 files changed, 12 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Mon Apr 19 12:46:15 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/timeout.rb (Timeout#timeout): propagate errors to the + caller. [ruby-dev:41010]' + Mon Apr 19 00:27:03 2010 NARUSE, Yui <naruse@ruby-lang.org> * 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 |