lib/zold/node/farmers.rb in zold-0.17.5 vs lib/zold/node/farmers.rb in zold-0.17.6
- old
+ new
@@ -59,18 +59,20 @@
@log = log
end
def up(score)
start = Time.now
- stdin, stdout = IO.pipe
+ stdout, stdin = IO.pipe
pid = Process.fork do
- stdout.puts(score.next)
+ stdin.puts(score.next)
end
at_exit { Farmers.kill(@log, pid, start) }
Process.wait
- stdout.close
- after = Score.parse(stdin.read.strip)
stdin.close
+ text = stdout.read.strip
+ stdout.close
+ raise "No score was calculated in the process ##{pid} in #{Age.new(start)}" if text.empty?
+ after = Score.parse(text)
@log.debug("Next score #{after.value}/#{after.strength} found in proc ##{pid} \
for #{after.host}:#{after.port} in #{Age.new(start)}: #{after.suffixes}")
after
end
end