From 1bb0917fa78b151729f8e40a98635ffd1ae72e09 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Tue, 8 Jun 2010 06:24:25 +0000 Subject: 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 --- ChangeLog | 5 +++++ lib/timeout.rb | 14 +++++++++++--- version.h | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a360e46e25..efe43f5266 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jun 8 15:23:10 2010 Nobuyoshi Nakada + + * lib/timeout.rb (Timeout#timeout): propagate errors to the + caller. [ruby-dev:41010]' + Tue Jun 8 15:15:18 2010 Nobuyoshi Nakada * lib/net/smtp.rb (Net::SMTP#rcptto_list): fixed typo. 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 diff --git a/version.h b/version.h index c0d9f70ea4..e56c88fe29 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2010-06-08" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20100608 -#define RUBY_PATCHLEVEL 273 +#define RUBY_PATCHLEVEL 274 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 -- cgit v1.2.3