I''ve got an app where it takes considerable time to process a list of requests from a user, and so would like to use periodically_call_remote to update a page showing how many requests have been processed. The relevant page uses javascript to hide the user submission form and replace with an animated "please wait" gif whilst the process runs, and I''d also like it to display the count of requests processed. Here''s a summary of the code: <%= periodically_call_remote(:update => "status", :url => {:action => "print_status"}, :frequency => 1) -%> <div id="spinner" style="display:none;"> <table border="0"> <tr> <td valign="middle" align="center"><img src="/images/load.gif" align="center" alt="Please wait image..."></td> <td valign="middle" align="center">Please wait...</td> </tr> <tr><td></td><td> <div id="status"></div> </td></tr> </table> </div> <div id="hide_me"> <!-- various instructions for the users --> <% form_remote_tag :url => {:action => :process}, :loading => "Element.hide(''hide_me''); Element.show(''spinner''); Element.show(''status'')", :complete => "Element.hide(''spinner''); Element.show(''hide_me''); Element.hide(''status'')", :update => "hide_me" do %> <!-- some radio buttons here --> <%= submit_tag("process") %><br> </form> <% end %> <!-- a table of options for users to choose from --> </div> The print_status action is simple: def print_status render :text => "#{session[:processed]} requests processed." end session[:processed] is initially set to 0 but 1 is added to it session.update run as each request is iterated over. The result of this is that the page initially displays "0 requests processed" in the correct place, but this text disappears after about 30 seconds. In another minute or so the browser times out and the "please wait" message and spinner vanish as well. Can anyone point out where I have got it wrong, above? Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 9 Jun 2008, at 16:35, Milo Thurston wrote:> > I''ve got an app where it takes considerable time to process a list of > requests from a user, and so would like to use > periodically_call_remote > to update a page showing how many requests have been processed. The > relevant page uses javascript to hide the user submission form and > replace with an animated "please wait" gif whilst the process runs, > and > I''d also like it to display the count of requests processed. Here''s a > summary of the code:How many mongrels are you running. if the answer is 1 (eg in development) then that''s why. Rails won''t process more than 1 concurrent request per mongrel. Fred> > > <%= periodically_call_remote(:update => "status", :url => {:action => > "print_status"}, :frequency => 1) -%> > <div id="spinner" style="display:none;"> > <table border="0"> > <tr> > <td valign="middle" align="center"><img src="/images/load.gif" > align="center" alt="Please wait image..."></td> > <td valign="middle" align="center">Please wait...</td> > </tr> > <tr><td></td><td> > <div id="status"></div> > </td></tr> > </table> > </div> > <div id="hide_me"> > <!-- various instructions for the users --> > <% form_remote_tag :url => {:action => :process}, > :loading => "Element.hide(''hide_me''); Element.show(''spinner''); > Element.show(''status'')", > :complete => "Element.hide(''spinner''); Element.show(''hide_me''); > Element.hide(''status'')", > :update => "hide_me" do %> > <!-- some radio buttons here --> > <%= submit_tag("process") %><br> > </form> > <% end %> > <!-- a table of options for users to choose from --> > </div> > > The print_status action is simple: > > def print_status > render :text => "#{session[:processed]} requests processed." > end > > session[:processed] is initially set to 0 but 1 is added to it > session.update run as each request is iterated over. > > The result of this is that the page initially displays "0 requests > processed" in the correct place, but this text disappears after > about 30 > seconds. In another minute or so the browser times out and the "please > wait" message and spinner vanish as well. > Can anyone point out where I have got it wrong, above? Thanks. > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> Rails won''t process more than 1 > concurrent request per mongrel.That''s it, then. Is there any way of running multiple mongrels in development? Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 9 Jun 2008, at 16:49, Milo Thurston wrote:> > Frederick Cheung wrote: >> Rails won''t process more than 1 >> concurrent request per mongrel. > > That''s it, then. > Is there any way of running multiple mongrels in development? > Thanks.Same way as you would in production :-) (mongrel cluster behind something (eg apache) proxying to it). That won''t solve your problem though: apache etc... will choose the mongrel to proxy to round-robin style, so half of your requests will be queued up behind this long running action. Long running actions aren''t a good idea for that reason (offload to backgroundrb or similar) Fred> > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> Long running actions > aren''t a good idea for that reason (offload to backgroundrb or similar)It looks like backgroundrb is the answer then. All that''s required is for the user to be notified when their data are ready for collection and the site already does that by e-mail. Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Backgroundrb worked nicely for that particular problem, but now another has cropped up. One particular page allows the user to search through the database to find and select some data that will be processed by the really long query that backgroundrb deals with. The sequence goes as follows: 1. User starts the search, browser displays animated gif and says "please wait." 2. After two minutes the browser times out and displays a blank page. 3. After three minutes the mysql query finishes and is stored in the mysql cache. 4. If the user tries the same query again the cached results appear in seconds. This is a bit of a nuisance. Does anyone have any suggestions for dealing with this one? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---