Module: Tweetwine::Http::Retrying
- Included in:
- Client
- Defined in:
- lib/tweetwine/http.rb
Constant Summary collapse
- MAX_RETRIES =
3
- RETRY_BASE_WAIT_TIMEOUT =
4
Instance Method Summary collapse
Instance Method Details
#retrying(max_retries = MAX_RETRIES, retry_base_wait_timeout = RETRY_BASE_WAIT_TIMEOUT) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tweetwine/http.rb', line 12 def (max_retries = MAX_RETRIES, retry_base_wait_timeout = RETRY_BASE_WAIT_TIMEOUT) retries = 0 begin yield rescue ConnectionError, TimeoutError if retries < max_retries retries += 1 timeout = retry_base_wait_timeout**retries CLI.ui.warn "Could not connect -- retrying in #{timeout} seconds" sleep timeout retry else raise end end end |