The only value Fifo.open returns is the name of the pipe.  Since the pipe's
name is known (stored in a constant) I don't need to capture  the return
value.  Flush is being called in the write method


---------- Forwarded message ----------
From: Gary Wright <gwtmp01 / mac.com>
Date: Sat, May 29, 2010 at 2:37 PM
Subject: Re: Non blocking IO during an AJAX request
To: ruby-talk ML <ruby-talk / ruby-lang.org>



On May 29, 2010, at 1:39 PM, Zundra Daniel wrote:

> 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
>
> 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!).


My first thought is buffering. I'm not sure what the semantics of Fifo.open
and Fifo.write are in your code since 'Fifo' isn't a standard Ruby class. It
also seems strange that you are calling Fifo.open but not capturing a return
value to be used anywhere. Perhaps you need to call flush somewhere after
Fifo.write to ensure the data is actually written to the fifo?  That might
explain why your send request is blocking since the data isn't in the fifo
yet.

Gary Wright