From: Zundra Daniel Date: 2010-05-30T02:39:03+09:00 Subject: Non blocking IO during an AJAX request --0016361e7b446a9a3f0487bf19d3 Content-Type: text/plain; charset=ISO-8859-1 I realize this is a Ruby mailing list but I have a Ruby/Rails question that seems to fall more on the Ruby side of the fence. I have a library file that creates a named pipe and writes the results of ping to the pipe. This method is called via a get AJAX request to kick off the process. def self.run(address) Fifo.open(PINGFIFO) Thread.new { IO.popen "ping -c 10 localhost" do |f| until f.eof? Fifo.write(f.gets, PINGFIFO) end end } end Then in a 2nd AJAX request I simply attempt to read the named pipe and return the string to the browser: def results if File.exists?(PINGFIFO) && File.pipe?(PINGFIFO) File.open(PINGFIFO, "r") do |f| render :text => f.readlines end end end The problem is the 2nd AJAX request simply hangs indefinitely. If I tail the pipe I can see data being written to it. Does anyone have any insight into why this is happening? It seemed like a simple enough problem but this one is throwing me for a loop (har!). --0016361e7b446a9a3f0487bf19d3--