summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/timeout.rb9
1 files changed, 7 insertions, 2 deletions
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