Re: Std. IO streams in Ruby

Frederick Cheung
2010-08-01T23:33:26Z

On Aug 1, 9:09 pm, Jatin Kumar
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:
> Frederick Cheung wrote:
> > On Aug 1, 7:29 pm, Jatin Kumar <li.
>
> >
>
> @Fred :-I have been looking over the internet for a solution but never
> got a real answer. Thanks for your help.
> My web app allows the user to run code in the browser window itself, so
> do i really need to do polling for that? I mean is there any better
> solution? If not, how can I use your approach. I have never tried
> something like that before, so a little confused. Can you explain it
> using a little code snippet? That would really help me out.

Don''t have any code snippets, just one way I''d try tackling
this - run
the commands from a separate ruby process and use whatever mechanism
you want (drb might be handy) to allow your controller action to get
from this process what the state of the command being run is.

> Also, the responses would be through AJAX. The user code will be sent
> back to server through an AJAX call, the file created for the code and
> then the response back to the browser(the output of file executed) in an
> AJAX call. So, that guarantee that next request will go to same rails
> instance, won''t that vanish away or not? Could be elaborate a
little bit
> on this too.

Unless I''ve misunderstood your command needs to keep running over the
course of several requests if you''re going to be getting input from
the users at the point. Unless you''re willing for your rails code to
just block until input is required ( not a great idea) you''ll need
some form of polling/comet.

> --
> Posted viahttp://www.ruby-forum.com/.