From: Bill Kelly Date: 2006-03-29T06:26:56+09:00 Subject: Re: timeout when listening with TCPServer From: "Eric Hodel" > >> Oh, hey, cool. Using the thread there looks like it >> ought to avoid the issue with Timeout firing in the >> middle of ensure blocks and circumventing them? >> >> I've been avoiding Timeout like "the plague" since >> running into that behavior. > > You've timed out, so that's what's supposed to happen :) Haha, yes... But it can be tricky... Timeout.timeout 2 do sleep 1.9 mutex.synchronize { @shared << "foo" } end ...the timeout can fire in such a way that the Thread#unlock in the ensure block of Thread#synchronize is skipped - leaving the mutex locked. I've been bitten by this... and it was pretty tough to track down. (Of course, I was calling some harmless looking method in the timeout block that just happened to be using a mutex as part of its implementation...) Regards, Bill