Some processes close their output channels and IO.select keeps
returning them as "readable", while IO#gets returns nil on them, thus
spending a lot of CPU looping through the same reader continuously
This commit is contained in:
Pavel Forkert
2013-01-07 02:30:56 +02:00
parent 553ac7f81f
commit aceea1472a
+6 -2
View File
@@ -275,8 +275,12 @@ private
loop do
io = IO.select(@readers.values, nil, nil, 30)
(io.nil? ? [] : io.first).each do |reader|
data = reader.gets
output_with_mutex name_for(@readers.invert[reader]), data
if reader.eof?
@readers.delete_if { |key, value| value == reader }
else
data = reader.gets
output_with_mutex name_for(@readers.invert[reader]), data
end
end
end
rescue Exception => ex