Module: HTTPClient::Timeout
- Included in:
- Session
- Defined in:
- lib/httpclient/timeout.rb
Instance Method Summary collapse
Instance Method Details
#timeout(sec, ex = nil, &block) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/httpclient/timeout.rb', line 110 def timeout(sec, ex = nil, &block) return yield if sec == nil or sec.zero? begin period = TIMEOUT_SCHEDULER.register(Thread.current, sec, ex) yield(sec) ensure TIMEOUT_SCHEDULER.cancel(period) end end |