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
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/httpclient/timeout.rb', line 122 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 |