Forum: Ruby on Rails Getting data back from thread spawn

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
PJ Hyett (Guest)
on 2006-01-17 21:53
(Received via mailing list)
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
Will B. (Guest)
on 2006-01-17 21:59
(Received via mailing list)
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
Ben M. (Guest)
on 2006-01-18 11:08
(Received via mailing list)
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
This topic is locked and can not be replied to.