How to control timeout exceptions

This is code that i am using for fetching updates from twitter. I used
SystemTimer gem from
thoughtwork(http://ph7spot.com/articles/system_timer) to ensure that we
don’t get anymore timeout exception and crashed page.As article
(http://ph7spot.com/articles/system_timer) points out weaknesses of
timeout.rb implemented in ruby 1.8. We are using ruby 1.8 in production.
After system_timer we also handle “rescue Twitter::Error” but they also
didn’t work. I know we can also option to configure timeout in the http
client library but i think these both should work fine.

We are using rails 2.2.2 and ruby 1.8.6. Here is my code.

TWITTER_SERVICE_TIMEOUT = 25s

begin
SystemTimer.timeout(TWITTER_SERVICE_TIMEOUT) do
c = Twitter::Client.new(:login =>
profile_twitter.email,:password => profile_twitter.password)
my_timeline = c.timeline_for(:me, :since => 30.minutes.ago)
end
rescue Twitter::RESTError => re

rescue Timeout::Error
  #my_timeline = nil

end

Exception i got mostly

/usr/lib/ruby/1.8/net/http.rb:560:in initialize' /usr/lib/ruby/1.8/net/http.rb:560:in open’
/usr/lib/ruby/1.8/net/http.rb:560:in connect' /usr/lib/ruby/1.8/timeout.rb:53:in timeout’
/usr/lib/ruby/1.8/timeout.rb:93:in timeout' /usr/lib/ruby/1.8/net/http.rb:560:in connect’
/usr/lib/ruby/1.8/net/http.rb:553:in do_start' /usr/lib/ruby/1.8/net/http.rb:542:in start’
/usr/lib/ruby/gems/1.8/gems/twitter4r-0.3.0/lib/twitter/client/base.rb:9:in
http_connect' /usr/lib/ruby/gems/1.8/gems/twitter4r-0.3.0/lib/twitter/client/timeline.rb:66:in timeline_for’

Maybe you want to check out Terminator? http://rubyforge.org/frs/?group_id=1024&release_id=26322 or http://codeforpeople.com/lib/ruby/terminator/

I cannot make promises but Ara is probably the guy to come up with a
solution for that kind of problem.

HTH
Robert

Toutes les grandes personnes ont d’abord été des enfants, mais peu
d’entre elles s’en souviennent.

All adults have been children first, but not many remember.

[Antoine de Saint-Exupéry]