> 
>>       @pool << Thread.current
> 
> The above line should be within the synchronize (above), or it might 
> spawn more than @max_size threads (I think).
> Replace with
>       @pool_mutex.synchronize do
>         while @pool.size >= @max_size
>           print "Pool is full; waiting to run #{args.join(',')}...\n" if 
> $DEBUG
>           # Sleep until some other thread calls @pool_cv.signal.
>           @pool_cv.wait(@pool_mutex)
>         end
>         @pool << Thread.current
>       end

I tried your suggestion but still get the error, and only when using 
backticks or any other method that reads from stdout or stderr.

>>       begin
>>         yield(*args)
>>       rescue => e
>>         exception(self, e, *args)
>>       ensure
>>         @pool_mutex.synchronize do
> 
> In reality you don't need to synchronize here, as the @pool size/add to 
> is synchronized elsewhere.  Taking this synch out may introduce new 
> problems, but...I'm not sure what they are :)

I'm not sure what you mean.  This makes sense to me, as we do not want 
more than one thread removing itself from the list at a time.

> My question is if the wait within the shutdown function will 'suck' 
> signals away from processes, decreasing the number that can go at a 
> time, if all are at the 'wait' phase.  Perhaps rethinking this code 
> would be nice :)

I'm not sure what you mean by "suck signals away from processes".  The 
shutdown method is just waiting until all threads have ended so we don't 
end our program before the threads are done.

It still seems to me that stdout and stderr have something to do with my 
problem, since it always occurs when using backticks or even 
win32/popen3 methods that read from stdout and stderr, but never with 
system.  Anyone else have any ideas on this?

Thanks for the reply.

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