Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How to control timeout exceptions.

Reply
Thread Tools

How to control timeout exceptions.

 
 
Junaid Junaidi
Guest
Posts: n/a
 
      07-23-2009
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,assword => 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'
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Robert Dober
Guest
Posts: n/a
 
      07-23-2009
<snip>
Maybe you want to check out Terminator?
http://rubyforge.org/frs/?group_id=3...ase_id=3D26322
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
--=20
Toutes les grandes personnes ont d=92abord =E9t=E9 des enfants, mais peu
d=92entre elles s=92en souviennent.

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

[Antoine de Saint-Exup=E9ry]

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Timeout::timeout and Socket timeout Mark Probert Ruby 1 10-06-2004 09:30 AM
Session contents lost despite Session.Timeout = 3000; and <sessionState mode="InProc" cookieless="false" timeout="300"> Carpe Diem ASP .Net 3 02-23-2004 07:10 PM
web.config session timeout and forms authentication timeout Do ASP .Net 2 11-23-2003 02:27 PM
Re: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Bob Johnson ASP .Net 0 08-07-2003 12:52 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57