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
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/httpclient/timeout.rb', line 123 def timeout(sec, ex = nil, &block) return yield if sec == nil or sec.zero? scheduler = nil begin scheduler = HTTPClient.timeout_scheduler period = scheduler.register(Thread.current, sec, ex) yield(sec) ensure scheduler.cancel(period) if scheduler and period end end |