aboutsummaryrefslogtreecommitdiffstats
path: root/lib/timeout.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/timeout.rb')
-rw-r--r--lib/timeout.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index afa4e0b68c..8c6ccb7128 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -28,13 +28,13 @@
class TimeoutError<Interrupt
end
-def timeout(sec)
+def timeout(sec, exception=TimeoutError)
return yield if sec == nil
begin
x = Thread.current
y = Thread.start {
sleep sec
- x.raise TimeoutError, "execution expired" if x.alive?
+ x.raise exception, "execution expired" if x.alive?
}
yield sec
# return true