begin Timeout::timeout(5) { @db.query(select * from books") } rescue Timeout::Error puts "Too slow, forget about it." end For instance, In above statment, @db.query will take 10 seconds to complete. But, I would like to kill that query after 5 seconds. how to kill the running @db.query in rescue statment.? With in 5 seconds whatever records fetched from db, How can i get those results? Any ideas??.. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2011/11/22 Sathiyaraj Gurusamy <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> I would like to kill that query after 5 seconds. > > how to kill the running @db.query in rescue statment.? With in 5 > seconds whatever records fetched from db, How can i get those results?As far as I understand the mechanisms of a RDBMS thats an "all or nothing" strategy. You could kill the task after 5 secs, but wouldn''t get anything or wait until finished and have it all. Another way would be to fetch in bunches of about 1000 Datasets and stop the time, and when the 5 secs are gone, you can use all the "bunches" you queried so far HTH Norbert -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.