Francis Cianfrocca wrote:
> On 9/15/06, Geff Geff <boing / boing.com> wrote:
>>
>>  vast amount of digging through google and writing test code, I came
>> across the following interesting behavior.  It seems that threads do not
>> have a parent child relationships.  So when one kills a thread, ruby
>> doesn't actually kill any threads that were started inside that thread.
>> To clarify, consider the following:
> 
> 
> Threads don't have any kind of parent-child relationship, as processes 
> do.
> None of the threading models that have seen wide use have a feature like
> this. What was your basis for thinking that they do?

What was I thinking was the following:  lets consider the case where you 
try to timeout a HTTP connect with the net/http stuff.  There are 
already "timeouts" in the HTTP class.  If my timeout times out before 
the library's timeout, I end up killing the http thread that is watching 
the tcpconnect thread.  The tcpconnect thread lives on until it's done. 
Maybe not such a big deal in thise case but the situation certainly 
could have been worse.  It could be kind of messy if you're using a 
library in general because you don't know if it's going ot call timeout 
of it's own and how that might impact resource allocation/deallocation. 
As far as the programmer is concerned, he / she timed out the http class 
and it should be (all) gone.  But it's not.  It's still hanging around. 
Just like my nested sleep was.

I don't have any basis for thinking there is a parent / child 
relationship.  Just sorta counter intuitive in the case of a nested 
timeout.  Because what programmer probably wants is a timeout on the 
thing that they are trying to timeout.  The *WHOLE* thing, not part of 
it, without verifying the libraries don't call timeout themselves.

Thoughts?

Seprately I'm having some issue with some of my activerecord objects 
sticking around in a long running deamon.  Not all, but some.  It's odd. 
I haven't found the problem yet, and I really don't know what's going 
on.  It's probably not timeout related because those would free up 
eventually.

Thanks so much for the comments thus far.

Geff

-- 
Posted via http://www.ruby-forum.com/.