From: Joel VanderWerf Date: 2008-02-10T07:24:43+09:00 Subject: Re: Timeout::Error Jeremy Thurgood wrote: > Joel VanderWerf wrote: ... >> It not a question of _what_ is recoverable, but _where_ it should be >> recovered. A timeout should only be caught at a point where it's >> expected. > > And if it's not expected, it should be allowed to crash my application? > You could make the same statement about any exception, really. Sorry, I wasn't clear. I'm not disagreeing with you, just suggesting that timeouts could be sensitive to location on the stack. Poorly said, but this is what it comes down to in code (not sure if this would break anything in stdlib though): require 'timeout' class StandardTimeoutError < StandardError; end module Timeout def self.standard_timeout(*args) timeout(*args) {yield} rescue TimeoutError raise StandardTimeoutError # maybe muck with the backtrace first end end begin Timeout.standard_timeout 1.0 do begin sleep rescue # inner puts "this should not happen" end end rescue => ex # outer p ex end -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407