Advertisement
saasbook

soa_timeout.rb

Apr 6th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.21 KB | None | 0 0
  1. require 'timeout'
  2. # call external service, but abort if no answer in 3 seconds:
  3. Timeout::timeout(3.0) do
  4.   begin
  5.     # potentially slow operation here
  6.   rescue Timeout::Error
  7.     # what to do if timeout occurs
  8.   end
  9. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement