From: Tim Pease Date: 2009-11-24T01:20:18+09:00 Subject: Re: issues with Kernel#select On Nov 23, 2009, at 3:02 AM, Robert Klemme wrote: > 2009/11/23 Eric Wong : >> Tim Pease wrote: > >>> Thanks for the answer. My suspicion is that the Ruby 1.8 green threads >>> can be woken up, but the Ruby 1.9 system threads "do the right thing"; >>> hence, the discrepancy in observed behavior. Good to know that it's >>> not a bug in 1.9. >>> >>> /me goes off to rework code >> >> Yeah, I expect thread.wakeup to only work on thread-aware things like >> sleeping on a condition variable or Thread.sleep. 1.8 wraps select() >> and uses that as the basis of its green thread implementation, so its >> harder to get around spurious wakeups. For reliably waking up IO#select >> I'd just write a byte to a pipe (useful with signal handlers, too, see: >> http://cr.yp.to/docs/selfpipe.html) > > Another approach would be to use #select with a timeout and regularly > check some condition. > Are you done yet? Are you done yet? Are you done yet? Are you done yet? I thought about that, but it's a little more code than I want to write. And I'd like my programs to *not* act like my 3 year old when he's tired ;) Closing the socket is my solution. This is shutdown code ... just need my thread back so I can do some cleanup. Thanks for the input. Blessings, TwP