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
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 On 1/17/06, PJ Hyett <pjhyett@gmail.com> wrote:> > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060117/70cecb15/attachment.html
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 PJ Hyett wrote:> 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails