diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-08 06:24:25 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-08 06:24:25 +0000 |
commit | 1bb0917fa78b151729f8e40a98635ffd1ae72e09 (patch) | |
tree | 426e89b2ad8d019a65124ae4ec565b4a156e8cba /lib/timeout.rb | |
parent | 0b1e93285ec4dafefb8277425e1ff58e5247715c (diff) |
merge revision(s) 27394:27397:
* lib/timeout.rb (Timeout#timeout): propagate errors to the
caller. [ruby-dev:41010]'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@28209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/timeout.rb')
-rw-r--r-- | lib/timeout.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb index 5a99c28092..e60b4e3f13 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -56,8 +56,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 } yield sec # return true @@ -73,7 +78,10 @@ module Timeout # would be expected outside. raise Error, e.message, e.backtrace ensure - y.kill if y and y.alive? + if y and y.alive? + y.kill + y.join # make sure y is dead. + end end end |