572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
# File 'lib/run_loop/core.rb', line 572
def self.write_request(run_loop, cmd, logger=nil)
repl_path = run_loop[:repl_path]
index = run_loop[:index]
cmd_str = "#{index}:#{escape_host_command(cmd)}"
RunLoop::Logging.log_debug(logger, cmd_str)
write_succeeded = false
2.times do |i|
RunLoop::Logging.log_debug(logger, "Trying write of command #{cmd_str} at index #{index}")
begin
RunLoop::Fifo.write(repl_path, cmd_str)
write_succeeded = validate_index_written(run_loop, index, logger)
rescue RunLoop::Fifo::NoReaderConfiguredError,
RunLoop::Fifo::WriteTimedOut => e
RunLoop::Logging.log_debug(logger, "Error while writing command (retry count #{i}). #{e}")
end
break if write_succeeded
end
unless write_succeeded
RunLoop::Logging.log_debug(logger, 'Failing...Raising RunLoop::WriteFailedError')
raise RunLoop::WriteFailedError.new("Trying write of command #{cmd_str} at index #{index}")
end
run_loop[:index] = index + 1
RunLoop::HostCache.default.write(run_loop) unless RunLoop::Environment.xtc?
index
end
|