diff options
Diffstat (limited to 'lib/timeout.rb')
-rw-r--r-- | lib/timeout.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb index f5c4e3cbf0..5c6a72652a 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -34,7 +34,7 @@ module Timeout end def timeout(sec, exception=Error) - return yield if sec == nil + return yield if sec == nil or sec.zero? begin x = Thread.current y = Thread.start { @@ -63,6 +63,12 @@ if __FILE__ == $0 p timeout(5, TimeoutError) { 45 } + p timeout(nil) { + 54 + } + p timeout(0) { + 54 + } p timeout(5) { loop { p 10 |