diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/timeout.rb | 14 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 17 insertions, 4 deletions
@@ -1,3 +1,8 @@ +Tue Jun 8 15:23:10 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/timeout.rb (Timeout#timeout): propagate errors to the + caller. [ruby-dev:41010]' + Tue Jun 8 15:15:18 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * 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 @@ -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 |