From: Eric Hodel Date: 2006-09-19T04:35:10+09:00 Subject: Re: Nested threading? implications to timeout() On Sep 16, 2006, at 12:40 AM, Arnaud Bergeron wrote: > On 9/15/06, Geff Geff wrote: >> Clearly by killing, what I would call the "parent thread", did not >> kill >> the child thread. And this would be okay, I think, except that >> the way >> the timeout class works is by starting a thread and killing it if it >> doesn't complete in the right amount of time. So if I were to wrap >> anything in "timeout() {}" it's possible that something else calls >> timeout inside that and then the thread is still alive, until some >> later >> time. Is this normal? > > Reading the timeout code I see that it creates a watcher thread to > provide the timeout. The block is executed on the current thread and > interruption is provided by raising an exception (from the watcher > tread) when the timeout expires. At the end of the method there is an > ensure to kill the watcher thread in any case so it would not > encounter the case you describe. > >> Can this cause memory leak? > > Due do what I described in the previous paragraph nested timeouts > won't cause any kind of leak. Nested timeouts have a different problem: http://blog.segment7.net/articles/2006/04/11/care-and-feeding-of- timeout-timeout -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com