Skip to content

Commit

Permalink
Fix #299 and #260
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fxposter committed Jan 7, 2013
1 parent 553ac7f commit aceea14
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/foreman/engine.rb
Expand Up @@ -275,8 +275,12 @@ def watch_for_output
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
Expand Down

0 comments on commit aceea14

Please sign in to comment.