On 9/16/06, Geff Geff <boing / boing.com> wrote:
 > I think if I timeout a timeout that my timeout is killing the "waiter"
> thread.  And since the waiter thread started the TCPconnect attempt
> thread that tcpconnect stays running until it ends, if it ends.  Kinda
> like my sleep thread example.  Is that not accurate?
>

I don't think so. Try the following:

---------------------------------------
require 'timeout'
begin
  timeout(2) {
    timeout(4) {
      sleep 6
      p "I finished"
    }
  }
rescue Timeout::Error
  p "timeout fired"
end

sleep 10
------------------------------------------
You'll see the timeout message after two seconds, and the program will
end ten seconds later without saying "I finished." You should be able
to ignore the fact that timeout is implemented with threads in the
first place. Or were you asking a different question?