Vance A Heron
11/25/2004 6:08:00 AM
Thank you Nobu. The patch fixes the problem!
I hope it or something like it makes it into the
next "official" version of ruby.
Once again, excellent response from the
Ruby community.
In answer to your questions, I had the statment
tgroup.threads.each {|t| print #{t} #{t.status}\n" }
which printed out several threads handles with no status.
The next_wait does a threads.emtpy? call, which
returned false (i.e. the group wasn't emtpy), which
was confirmed by seeing the list of thread handles
in the print stmt. I did not check the wait_queue.
I had set the "abort_on_exception" variable to true
to catch any threads that died unexpectedly - it
never was executed, so I think all the threads completed
normaly.
Vance
On Wed, 2004-11-24 at 15:26, nobu.nokada@softhome.net wrote:
> Hi,
>
> At Thu, 25 Nov 2004 04:09:24 +0900,
> Vance A Heron wrote in [ruby-talk:121320]:
> > For large trees, the code never exited, and looking I found
> > tgroup to contain several threads with a status of nil.
> >
> > I first added the line
> > abort_on_execption = true
> > thinking that some of the threads were dying unexpectedly,
> > and being ignored. Stil no joy.
>
> Yes, Thread#status returns nil the thread died by an
> exception. Does the following patch help you?
>
> > In desperation i've added the following.
> > near the begining of the file after including thwait
> > ----
> > class ThreadsWait
> > attr_accessor :threads
> > end
> > ----
> >
> > Immediately prior to the 2nd while
> > ---
> > tgroup.threads.delete_if {|t| t.status == nil }
> > ---
>
> Can you inspect @wait_queue of tgroup and Thread.list at that
> time? I.E., !tgroup.threads.empty? and !tgroup.threads.all?
>
>
> Index: lib/thwait.rb
> ===================================================================
> RCS file: /cvs/ruby/src/ruby/lib/thwait.rb,v
> retrieving revision 1.8
> diff -U2 -p -d -r1.8 thwait.rb
> --- lib/thwait.rb 18 Apr 2004 23:19:46 -0000 1.8
> +++ lib/thwait.rb 24 Nov 2004 23:23:48 -0000
> @@ -118,6 +118,9 @@ class ThreadsWait
> for th in threads
> Thread.start(th) do |t|
> - t.join
> - @wait_queue.push t
> + begin
> + t.join
> + ensure
> + @wait_queue.push t
> + end
> end
> end
>