On 9/17/06, Francis Cianfrocca <garbagecat10 / gmail.com> wrote:
> 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?

FYI: Eric Hodel has written a post about nested timeouts:
http://blog.segment7.net/articles/2006/04/11/care-and-feeding-of-timeout-timeout