Getting data back from thread spawn

I have a script that needs to be run, that in some cases will take
longer than the server timeout. So, I’m thinking just throw the script
in its own thread, but I need to be able to get the data back from
that thread and refresh the page with the data returned. Any
suggestions how to do this?


This is a noob answer, but couldn’t you fetch the data asynchronously
the Rails AJAX methods? Or does that also encounter the server timeout

If the server timeouts on AJAX calls, I think your only other option is
have the thread record its data somewhere (DB, flatfile, etc) and reload
page on regular intervals using a periodic_call_remote observer to see
the thread has made the data available yet…


You could send back a static html page with a little animated “progress
bar” gif and with
the “refresh” header set to check back with the server every few
seconds. If the server’s
still not ready it just sends back the same “in progress” page… until
it has the
results. I think that’s how them fancy travel sites (like orbitz??) do


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs