627: def reap_dead_workers(reason='unknown')
628: if @workers.list.length > 0
629: STDERR.puts "#{Time.now}: Reaping #{@workers.list.length} threads for slow workers because of '#{reason}'"
630: error_msg = "Mongrel timed out this thread: #{reason}"
631: mark = Time.now
632: @workers.list.each do |w|
633: w[:started_on] = Time.now if not w[:started_on]
634:
635: if mark - w[:started_on] > @death_time + @timeout
636: STDERR.puts "Thread #{w.inspect} is too old, killing."
637: w.raise(TimeoutError.new(error_msg))
638: end
639: end
640: end
641:
642: return @workers.list.length
643: end