Getting data back from thread spawn


#1

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?

Thanks,
PJ


#2

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

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

-Will


#3

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
it…

b