Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'timeout'
- # call external service, but abort if no answer in 3 seconds:
- Timeout::timeout(3.0) do
- begin
- # potentially slow operation here
- rescue Timeout::Error
- # what to do if timeout occurs
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement