summaryrefslogtreecommitdiffstats
path: root/lib/timeout.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-16 03:37:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-16 03:37:23 +0000
commitaefad35e2c5ef6077a095b66e2d59602d36f83ef (patch)
treefc3d9a3b547bcab1a95ff2fa64c58b0c4c7cd5f0 /lib/timeout.rb
parent4e787e1242e1a63b55c030e9e0164e00130fd1c6 (diff)
downloadruby-aefad35e2c5ef6077a095b66e2d59602d36f83ef.tar.gz
ruby-aefad35e2c5ef6077a095b66e2d59602d36f83ef.tar.xz
ruby-aefad35e2c5ef6077a095b66e2d59602d36f83ef.zip
* lib/timeout.rb (timeout): new optional argument to specify an
exception class. * lib/resolv.rb: use Resolv::ResolvTimeout for internal timeout to avoid problem with timeout of application. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 afa4e0b68..8c6ccb712 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